This commit is contained in:
Looly 2024-08-27 08:52:36 +08:00
parent 24803f8f0c
commit d53d7a966c
2 changed files with 32 additions and 32 deletions

View File

@ -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);
}

View File

@ -90,10 +90,10 @@ public class ExcelWriter extends ExcelBase<ExcelWriter, ExcelWriteConfig> {
/**
* 构造默认写出到第一个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<ExcelWriter, ExcelWriteConfig> {
/**
* 构造
*
* @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<ExcelWriter, ExcelWriteConfig> {
* 此构造不传入写出的Excel文件路径只能调用{@link #flush(OutputStream)}方法写出到流<br>
* 若写出到文件还需调用{@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));
}
/**