提交 eb8c7d54 编写于 作者: 庄家钜's avatar 庄家钜

修改模板提示

上级 6ff6fbff
......@@ -66,7 +66,6 @@ public class ExcelWriterBuilder extends AbstractExcelWriterParameterBuilder<Exce
return this;
}
public ExcelWriterBuilder excelType(ExcelTypeEnum excelType) {
writeWorkbook.setExcelType(excelType);
return this;
......@@ -95,21 +94,32 @@ public class ExcelWriterBuilder extends AbstractExcelWriterParameterBuilder<Exce
return this;
}
/**
* Template file.
* This file is read into memory, excessive cases can lead to OOM.
*/
public ExcelWriterBuilder withTemplate(InputStream templateInputStream) {
writeWorkbook.setTemplateInputStream(templateInputStream);
return this;
}
/**
* Template file.
* This file is read into memory, excessive cases can lead to OOM.
*/
public ExcelWriterBuilder withTemplate(File templateFile) {
writeWorkbook.setTemplateFile(templateFile);
return this;
}
/**
* Template file.
* This file is read into memory, excessive cases can lead to OOM.
*/
public ExcelWriterBuilder withTemplate(String pathName) {
return withTemplate(new File(pathName));
}
public ExcelWriter build() {
return new ExcelWriter(writeWorkbook);
}
......
......@@ -49,7 +49,8 @@ public class WriteWorkbook extends WriteBasicParameter {
private InputStream templateInputStream;
/**
* Template file
* Template file.
* This file is read into memory, excessive cases can lead to OOM.
* <p>
* If 'inputStream' and 'file' all not empty, file first
*/
......@@ -66,7 +67,6 @@ public class WriteWorkbook extends WriteBasicParameter {
* Whether the encryption
* <p>
* WARRING:Encryption is when the entire file is read into memory, so it is very memory intensive.
*
*/
private String password;
/**
......
......@@ -401,6 +401,7 @@ public class WriteTest {
String templateFileName = TestFileUtil.getPath() + "demo" + File.separator + "demo.xlsx";
String fileName = TestFileUtil.getPath() + "templateWrite" + System.currentTimeMillis() + ".xlsx";
// 这里 需要指定写用哪个class去写,然后写到第一个sheet,名字为模板 然后文件流会自动关闭
// 这里要注意 withTemplate 的模板文件会全量存储在内存里面,所以尽量不要用于追加文件,如果文件模板文件过大会OOM
EasyExcel.write(fileName, DemoData.class).withTemplate(templateFileName).sheet().doWrite(data());
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册