From 3535ac64f79c7c3d8e03d8ed2a996ebdfab1ff92 Mon Sep 17 00:00:00 2001 From: Charles7c Date: Tue, 24 Sep 2024 22:07:52 +0800 Subject: [PATCH] =?UTF-8?q?refactor(file/excel):=20=E5=AF=BC=E5=87=BA?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E5=A2=9E=E5=8A=A0=E6=8E=92=E9=99=A4=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../starter/file/excel/util/ExcelUtils.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/continew-starter-file/continew-starter-file-excel/src/main/java/top/continew/starter/file/excel/util/ExcelUtils.java b/continew-starter-file/continew-starter-file-excel/src/main/java/top/continew/starter/file/excel/util/ExcelUtils.java index 0ac894eb..0f3b74ec 100644 --- a/continew-starter-file/continew-starter-file-excel/src/main/java/top/continew/starter/file/excel/util/ExcelUtils.java +++ b/continew-starter-file/continew-starter-file-excel/src/main/java/top/continew/starter/file/excel/util/ExcelUtils.java @@ -27,8 +27,10 @@ import org.slf4j.LoggerFactory; import top.continew.starter.core.exception.BaseException; import top.continew.starter.file.excel.converter.ExcelBigNumberConverter; +import java.util.Collections; import java.util.Date; import java.util.List; +import java.util.Set; /** * Excel 工具类 @@ -52,21 +54,23 @@ public class ExcelUtils { * @param response 响应对象 */ public static void export(List list, String fileName, Class clazz, HttpServletResponse response) { - export(list, fileName, "Sheet1", clazz, response); + export(list, fileName, "Sheet1", Collections.emptySet(), clazz, response); } /** * 导出 * - * @param list 导出数据集合 - * @param fileName 文件名 - * @param sheetName 工作表名称 - * @param clazz 导出数据类型 - * @param response 响应对象 + * @param list 导出数据集合 + * @param fileName 文件名 + * @param sheetName 工作表名称 + * @param excludeColumnFieldNames 排除字段 + * @param clazz 导出数据类型 + * @param response 响应对象 */ public static void export(List list, String fileName, String sheetName, + Set excludeColumnFieldNames, Class clazz, HttpServletResponse response) { try { @@ -81,6 +85,7 @@ public class ExcelUtils { // 自动转换大数值 .registerConverter(new ExcelBigNumberConverter()) .sheet(sheetName) + .excludeColumnFieldNames(excludeColumnFieldNames) .doWrite(list); } catch (Exception e) { log.error("Export excel occurred an error: {}. fileName: {}.", e.getMessage(), fileName, e);