From 4f9bcc70739ec0f4190841ecd751429e15b18881 Mon Sep 17 00:00:00 2001 From: huaiyu Date: Thu, 10 Oct 2019 15:20:26 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=88=E5=B9=B6=E5=86=B2=E7=AA=81=20?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8E=9F=E6=9D=A5=E7=9A=84=E5=86=99=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/alibaba/excel/write/ExcelBuilderImpl.java | 10 ++++++++-- .../write/metadata/holder/WriteWorkbookHolder.java | 8 ++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) 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; + } }