From 7b9890ae517ac3eb98c80223f8e6713958ddba82 Mon Sep 17 00:00:00 2001 From: Jiaju Zhuang Date: Tue, 5 Nov 2019 19:30:27 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9Esince?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/alibaba/excel/write/ExcelBuilderImpl.java | 7 +++++-- .../alibaba/easyexcel/test/demo/write/WriteTest.java | 2 ++ .../easyexcel/test/temp/read/HeadReadTest.java | 12 ++++++++++++ update.md | 4 +++- 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/alibaba/excel/write/ExcelBuilderImpl.java b/src/main/java/com/alibaba/excel/write/ExcelBuilderImpl.java index 9658f553..59f78bfb 100644 --- a/src/main/java/com/alibaba/excel/write/ExcelBuilderImpl.java +++ b/src/main/java/com/alibaba/excel/write/ExcelBuilderImpl.java @@ -25,10 +25,13 @@ public class ExcelBuilderImpl implements ExcelBuilder { private ExcelWriteFillExecutor excelWriteFillExecutor; private ExcelWriteAddExecutor excelWriteAddExecutor; + static { + // Create temporary cache directory at initialization time to avoid POI concurrent write bugs + FileUtils.createPoiFilesDirectory(); + } + public ExcelBuilderImpl(WriteWorkbook writeWorkbook) { try { - // Create temporary cache directory at initialization time to avoid POI concurrent write bugs - FileUtils.createPoiFilesDirectory(); context = new WriteContextImpl(writeWorkbook); } catch (RuntimeException e) { finishOnException(); diff --git a/src/test/java/com/alibaba/easyexcel/test/demo/write/WriteTest.java b/src/test/java/com/alibaba/easyexcel/test/demo/write/WriteTest.java index 3e27bd38..7b7d6b35 100644 --- a/src/test/java/com/alibaba/easyexcel/test/demo/write/WriteTest.java +++ b/src/test/java/com/alibaba/easyexcel/test/demo/write/WriteTest.java @@ -73,6 +73,8 @@ public class WriteTest { * 2. 根据自己或者排除自己需要的列 *

* 3. 直接写即可 + * + * @since 2.1.1 */ @Test public void excludeOrIncludeWrite() { diff --git a/src/test/java/com/alibaba/easyexcel/test/temp/read/HeadReadTest.java b/src/test/java/com/alibaba/easyexcel/test/temp/read/HeadReadTest.java index 5127f72f..b046d143 100644 --- a/src/test/java/com/alibaba/easyexcel/test/temp/read/HeadReadTest.java +++ b/src/test/java/com/alibaba/easyexcel/test/temp/read/HeadReadTest.java @@ -8,6 +8,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.alibaba.excel.EasyExcel; +import com.alibaba.excel.cache.Ehcache; /** * 临时测试 @@ -25,4 +26,15 @@ public class HeadReadTest { } + @Test + public void testCache() throws Exception { + File file = new File("D:\\test\\headt1.xls"); + EasyExcel.read(file, HeadReadData.class, new HDListener()).readCache(new Ehcache(20)).sheet(0).doRead(); + + LOGGER.info("------------------"); + EasyExcel.read(file, HeadReadData.class, new HDListener()).readCache(new Ehcache(20)).sheet(0).doRead(); + LOGGER.info("------------------"); + EasyExcel.read(file, HeadReadData.class, new HDListener()).readCache(new Ehcache(20)).sheet(0).doRead(); + } + } diff --git a/update.md b/update.md index 9bd246e5..eaaed2bf 100644 --- a/update.md +++ b/update.md @@ -1,3 +1,5 @@ +# 2.1.2 + # 2.1.1 * 发布正式版 * 修改map返回为LinkedHashMap @@ -61,7 +63,7 @@ * 修复监听器转换异常会重复提示的bug # 2.0.1 -* 降级poi为3.1.7 兼容jdk6 +* 降级poi为3.17 兼容jdk6 # 2.0.0 * 修复当cell为空可能会抛出空指针的bug