diff --git a/src/main/java/com/alibaba/excel/write/ExcelBuilderImpl.java b/src/main/java/com/alibaba/excel/write/ExcelBuilderImpl.java index 1928447..c1a00c2 100644 --- a/src/main/java/com/alibaba/excel/write/ExcelBuilderImpl.java +++ b/src/main/java/com/alibaba/excel/write/ExcelBuilderImpl.java @@ -98,10 +98,16 @@ public class ExcelBuilderImpl implements ExcelBuilder { @Override public void addContent(List data, WriteSheet writeSheet, WriteTable writeTable, String password) { try { - context.currentSheet(writeSheet); + if (data == null) { + return; + } + context.currentSheet(writeSheet, WriteTypeEnum.ADD); context.currentTable(writeTable); context.setPassword(password); - doAddContent(data); + if (excelWriteAddExecutor == null) { + excelWriteAddExecutor = new ExcelWriteAddExecutor(context); + } + excelWriteAddExecutor.add(data); } catch (RuntimeException e) { finish(); throw e; diff --git a/src/main/java/com/alibaba/excel/write/metadata/holder/WriteWorkbookHolder.java b/src/main/java/com/alibaba/excel/write/metadata/holder/WriteWorkbookHolder.java index 931a450..65559db 100644 --- a/src/main/java/com/alibaba/excel/write/metadata/holder/WriteWorkbookHolder.java +++ b/src/main/java/com/alibaba/excel/write/metadata/holder/WriteWorkbookHolder.java @@ -261,4 +261,12 @@ public class WriteWorkbookHolder extends AbstractWriteHolder { public HolderEnum holderType() { return HolderEnum.WORKBOOK; } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } }