From d53d7a966c101bf9e01935e5ad1994eeb6b1ee46 Mon Sep 17 00:00:00 2001 From: Looly Date: Tue, 27 Aug 2024 08:52:36 +0800 Subject: [PATCH] fix code --- .../dromara/hutool/poi/excel/ExcelUtil.java | 24 +++++------ .../hutool/poi/excel/writer/ExcelWriter.java | 40 +++++++++---------- 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/hutool-poi/src/main/java/org/dromara/hutool/poi/excel/ExcelUtil.java b/hutool-poi/src/main/java/org/dromara/hutool/poi/excel/ExcelUtil.java index 69f383239..1a97745a8 100644 --- a/hutool-poi/src/main/java/org/dromara/hutool/poi/excel/ExcelUtil.java +++ b/hutool-poi/src/main/java/org/dromara/hutool/poi/excel/ExcelUtil.java @@ -298,12 +298,12 @@ public class ExcelUtil { /** * 获得{@link ExcelWriter},默认写出到第一个sheet * - * @param destFilePath 目标文件路径 + * @param templateFilePath 模板文件路径 * @return {@link ExcelWriter} */ - public static ExcelWriter getWriter(final String destFilePath) { + public static ExcelWriter getWriter(final String templateFilePath) { try { - return new ExcelWriter(destFilePath); + return new ExcelWriter(templateFilePath); } catch (final NoClassDefFoundError e) { throw new DependencyException(ObjUtil.defaultIfNull(e.getCause(), e), PoiChecker.NO_POI_ERROR_MSG); } @@ -327,12 +327,12 @@ public class ExcelUtil { /** * 获得{@link ExcelWriter},默认写出到第一个sheet,名字为sheet1 * - * @param destFile 目标文件 + * @param templateFile 目标文件 * @return {@link ExcelWriter} */ - public static ExcelWriter getWriter(final File destFile) { + public static ExcelWriter getWriter(final File templateFile) { try { - return new ExcelWriter(destFile); + return new ExcelWriter(templateFile); } catch (final NoClassDefFoundError e) { throw new DependencyException(ObjUtil.defaultIfNull(e.getCause(), e), PoiChecker.NO_POI_ERROR_MSG); } @@ -341,13 +341,13 @@ public class ExcelUtil { /** * 获得{@link ExcelWriter} * - * @param destFilePath 目标文件路径 + * @param templateFilePath 目标文件路径 * @param sheetName sheet表名 * @return {@link ExcelWriter} */ - public static ExcelWriter getWriter(final String destFilePath, final String sheetName) { + public static ExcelWriter getWriter(final String templateFilePath, final String sheetName) { try { - return new ExcelWriter(destFilePath, sheetName); + return new ExcelWriter(templateFilePath, sheetName); } catch (final NoClassDefFoundError e) { throw new DependencyException(ObjUtil.defaultIfNull(e.getCause(), e), PoiChecker.NO_POI_ERROR_MSG); } @@ -356,13 +356,13 @@ public class ExcelUtil { /** * 获得{@link ExcelWriter} * - * @param destFile 目标文件 + * @param templateFilePath 目标文件 * @param sheetName sheet表名 * @return {@link ExcelWriter} */ - public static ExcelWriter getWriter(final File destFile, final String sheetName) { + public static ExcelWriter getWriter(final File templateFilePath, final String sheetName) { try { - return new ExcelWriter(destFile, sheetName); + return new ExcelWriter(templateFilePath, sheetName); } catch (final NoClassDefFoundError e) { throw new DependencyException(ObjUtil.defaultIfNull(e.getCause(), e), PoiChecker.NO_POI_ERROR_MSG); } diff --git a/hutool-poi/src/main/java/org/dromara/hutool/poi/excel/writer/ExcelWriter.java b/hutool-poi/src/main/java/org/dromara/hutool/poi/excel/writer/ExcelWriter.java index 9ac8eb36a..8ba597592 100644 --- a/hutool-poi/src/main/java/org/dromara/hutool/poi/excel/writer/ExcelWriter.java +++ b/hutool-poi/src/main/java/org/dromara/hutool/poi/excel/writer/ExcelWriter.java @@ -90,10 +90,10 @@ public class ExcelWriter extends ExcelBase { /** * 构造,默认写出到第一个sheet,第一个sheet名为sheet1 * - * @param destFilePath 目标文件路径,可以不存在 + * @param templateFilePath 模板文件,不存在则默认为目标写出文件 */ - public ExcelWriter(final String destFilePath) { - this(destFilePath, null); + public ExcelWriter(final String templateFilePath) { + this(templateFilePath, null); } /** @@ -112,33 +112,33 @@ public class ExcelWriter extends ExcelBase { /** * 构造 * - * @param destFilePath 目标文件路径,可以不存在 - * @param sheetName sheet名,第一个sheet名并写出到此sheet,例如sheet1 + * @param templateFilePath 模板文件,不存在则默认为目标写出文件 + * @param sheetName sheet名,第一个sheet名并写出到此sheet,例如sheet1 */ - public ExcelWriter(final String destFilePath, final String sheetName) { - this(FileUtil.file(destFilePath), sheetName); + public ExcelWriter(final String templateFilePath, final String sheetName) { + this(FileUtil.file(templateFilePath), sheetName); } /** * 构造,默认写出到第一个sheet,第一个sheet名为sheet1 * - * @param destFile 目标文件,可以不存在 + * @param templateFile 模板文件,不存在则默认为目标写出文件 */ - public ExcelWriter(final File destFile) { - this(destFile, null); + public ExcelWriter(final File templateFile) { + this(templateFile, null); } /** * 构造 * - * @param targetFile 目标文件,可以不存在 - * @param sheetName sheet名,做为第一个sheet名并写出到此sheet,例如sheet1 + * @param templateFile 模板文件,不存在则默认为目标写出文件 + * @param sheetName sheet名,做为第一个sheet名并写出到此sheet,例如sheet1 */ - public ExcelWriter(final File targetFile, final String sheetName) { - this(WorkbookUtil.createBookForWriter(targetFile), sheetName); + public ExcelWriter(final File templateFile, final String sheetName) { + this(WorkbookUtil.createBookForWriter(templateFile), sheetName); - if (!FileUtil.exists(targetFile)) { - this.targetFile = targetFile; + if (!FileUtil.exists(templateFile)) { + this.targetFile = templateFile; } else { // 如果是已经存在的文件,则作为模板加载,此时不能写出到模板文件 // 初始化模板 @@ -151,11 +151,11 @@ public class ExcelWriter extends ExcelBase { * 此构造不传入写出的Excel文件路径,只能调用{@link #flush(OutputStream)}方法写出到流
* 若写出到文件,还需调用{@link #setTargetFile(File)}方法自定义写出的文件,然后调用{@link #flush()}方法写出到文件 * - * @param workbook {@link Workbook} - * @param sheetName sheet名,做为第一个sheet名并写出到此sheet,例如sheet1 + * @param templateWorkbook 模板{@link Workbook} + * @param sheetName sheet名,做为第一个sheet名并写出到此sheet,例如sheet1 */ - public ExcelWriter(final Workbook workbook, final String sheetName) { - this(SheetUtil.getOrCreateSheet(workbook, sheetName)); + public ExcelWriter(final Workbook templateWorkbook, final String sheetName) { + this(SheetUtil.getOrCreateSheet(templateWorkbook, sheetName)); } /**