From 604ce6f0fa1623533ebb0560b579cc23398633d6 Mon Sep 17 00:00:00 2001 From: Jiaju Zhuang Date: Thu, 4 Nov 2021 21:38:35 +0800 Subject: [PATCH 1/5] =?UTF-8?q?*=20=E8=B0=83=E6=95=B4=E8=AF=BB=E5=86=99?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E5=A4=A7=E5=B0=8F=EF=BC=8C=E9=98=B2=E6=AD=A2?= =?UTF-8?q?=E5=A4=A7=E6=89=B9=E9=87=8F=E5=86=99=E7=9A=84=E6=97=B6=E5=80=99?= =?UTF-8?q?=E5=8F=AF=E8=83=BD=E4=BC=9Afull=20gc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- pom.xml | 2 +- src/main/java/com/alibaba/excel/cache/Ehcache.java | 2 +- .../java/com/alibaba/excel/metadata/csv/CsvSheet.java | 2 +- .../alibaba/excel/read/listener/PageReadListener.java | 2 +- .../easyexcel/test/core/large/LargeDataTest.java | 8 ++++---- .../test/demo/read/CellDataDemoHeadDataListener.java | 10 +++++----- .../test/demo/read/ConverterDataListener.java | 8 ++++---- .../easyexcel/test/demo/read/DemoDataListener.java | 4 ++-- .../test/demo/read/DemoExceptionListener.java | 2 +- .../easyexcel/test/demo/read/DemoHeadDataListener.java | 9 ++++----- .../test/demo/read/IndexOrNameDataListener.java | 8 ++++---- .../easyexcel/test/demo/read/NoModelDataListener.java | 8 ++++---- .../com/alibaba/easyexcel/test/demo/read/ReadTest.java | 2 +- .../easyexcel/test/demo/web/UploadDataListener.java | 2 +- .../alibaba/easyexcel/test/temp/LockDataListener.java | 2 +- .../alibaba/easyexcel/test/temp/read/HDListener.java | 2 +- .../alibaba/easyexcel/test/temp/read/HeadListener.java | 2 +- .../alibaba/easyexcel/test/temp/simple/HgListener.java | 8 ++++---- .../easyexcel/test/temp/simple/RepeatListener.java | 2 +- update.md | 3 +++ 21 files changed, 46 insertions(+), 44 deletions(-) diff --git a/README.md b/README.md index ebba173e..3a22ff64 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ Java解析、生成Excel比较有名的框架有Apache poi、jxl。但他们都 com.alibaba easyexcel - 3.0.3 + 3.0.4 ``` diff --git a/pom.xml b/pom.xml index c5aec18c..89f4c341 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 com.alibaba easyexcel - 3.0.3 + 3.0.4 jar easyexcel diff --git a/src/main/java/com/alibaba/excel/cache/Ehcache.java b/src/main/java/com/alibaba/excel/cache/Ehcache.java index a5250900..b7b542ee 100644 --- a/src/main/java/com/alibaba/excel/cache/Ehcache.java +++ b/src/main/java/com/alibaba/excel/cache/Ehcache.java @@ -24,7 +24,7 @@ import org.ehcache.config.units.MemoryUnit; */ @Slf4j public class Ehcache implements ReadCache { - public static final int BATCH_COUNT = 1000; + public static final int BATCH_COUNT = 100; /** * Key index */ diff --git a/src/main/java/com/alibaba/excel/metadata/csv/CsvSheet.java b/src/main/java/com/alibaba/excel/metadata/csv/CsvSheet.java index 79331677..725addbc 100644 --- a/src/main/java/com/alibaba/excel/metadata/csv/CsvSheet.java +++ b/src/main/java/com/alibaba/excel/metadata/csv/CsvSheet.java @@ -85,7 +85,7 @@ public class CsvSheet implements Sheet, Closeable { public CsvSheet(CsvWorkbook csvWorkbook, Appendable out) { this.csvWorkbook = csvWorkbook; this.out = out; - this.rowCacheCount = 3000; + this.rowCacheCount = 100; this.csvFormat = CSVFormat.DEFAULT; this.lastRowIndex = -1; } diff --git a/src/main/java/com/alibaba/excel/read/listener/PageReadListener.java b/src/main/java/com/alibaba/excel/read/listener/PageReadListener.java index c692bf10..0795a9e4 100644 --- a/src/main/java/com/alibaba/excel/read/listener/PageReadListener.java +++ b/src/main/java/com/alibaba/excel/read/listener/PageReadListener.java @@ -17,7 +17,7 @@ public class PageReadListener implements ReadListener { /** * Single handle the amount of data */ - public static int BATCH_COUNT = 3000; + public static int BATCH_COUNT = 100; /** * Temporary storage of data */ diff --git a/src/test/java/com/alibaba/easyexcel/test/core/large/LargeDataTest.java b/src/test/java/com/alibaba/easyexcel/test/core/large/LargeDataTest.java index a438a2ee..c7f202e5 100644 --- a/src/test/java/com/alibaba/easyexcel/test/core/large/LargeDataTest.java +++ b/src/test/java/com/alibaba/easyexcel/test/core/large/LargeDataTest.java @@ -59,7 +59,7 @@ public class LargeDataTest { public void t02Fill() { ExcelWriter excelWriter = EasyExcel.write(fileFill07).withTemplate(template07).build(); WriteSheet writeSheet = EasyExcel.writerSheet().build(); - for (int j = 0; j < 100; j++) { + for (int j = 0; j < 5000; j++) { excelWriter.fill(data(), writeSheet); LOGGER.info("{} fill success.", j); } @@ -72,7 +72,7 @@ public class LargeDataTest { long start = System.currentTimeMillis(); ExcelWriter excelWriter = EasyExcel.write(fileCsv).build(); WriteSheet writeSheet = EasyExcel.writerSheet().build(); - for (int j = 0; j < 100; j++) { + for (int j = 0; j < 5000; j++) { excelWriter.write(data(), writeSheet); LOGGER.info("{} write success.", j); } @@ -97,7 +97,7 @@ public class LargeDataTest { long start = System.currentTimeMillis(); excelWriter = EasyExcel.write(fileWrite07, LargeData.class).build(); writeSheet = EasyExcel.writerSheet().build(); - for (int j = 0; j < 100; j++) { + for (int j = 0; j < 5000; j++) { excelWriter.write(data(), writeSheet); LOGGER.info("{} write success.", j); } @@ -130,7 +130,7 @@ public class LargeDataTest { private List data() { List list = new ArrayList<>(); - int size = i + 5000; + int size = i + 100; for (; i < size; i++) { LargeData largeData = new LargeData(); list.add(largeData); diff --git a/src/test/java/com/alibaba/easyexcel/test/demo/read/CellDataDemoHeadDataListener.java b/src/test/java/com/alibaba/easyexcel/test/demo/read/CellDataDemoHeadDataListener.java index 53e0bf68..aba35665 100644 --- a/src/test/java/com/alibaba/easyexcel/test/demo/read/CellDataDemoHeadDataListener.java +++ b/src/test/java/com/alibaba/easyexcel/test/demo/read/CellDataDemoHeadDataListener.java @@ -3,13 +3,13 @@ package com.alibaba.easyexcel.test.demo.read; import java.util.ArrayList; import java.util.List; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import com.alibaba.excel.context.AnalysisContext; import com.alibaba.excel.event.AnalysisEventListener; import com.alibaba.fastjson.JSON; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + /** * 读取头 * @@ -18,9 +18,9 @@ import com.alibaba.fastjson.JSON; public class CellDataDemoHeadDataListener extends AnalysisEventListener { private static final Logger LOGGER = LoggerFactory.getLogger(CellDataDemoHeadDataListener.class); /** - * 每隔5条存储数据库,实际使用中可以3000条,然后清理list ,方便内存回收 + * 每隔5条存储数据库,实际使用中可以100条,然后清理list ,方便内存回收 */ - private static final int BATCH_COUNT = 5; + private static final int BATCH_COUNT = 100; List list = new ArrayList(); @Override diff --git a/src/test/java/com/alibaba/easyexcel/test/demo/read/ConverterDataListener.java b/src/test/java/com/alibaba/easyexcel/test/demo/read/ConverterDataListener.java index d343964d..d4717468 100644 --- a/src/test/java/com/alibaba/easyexcel/test/demo/read/ConverterDataListener.java +++ b/src/test/java/com/alibaba/easyexcel/test/demo/read/ConverterDataListener.java @@ -3,13 +3,13 @@ package com.alibaba.easyexcel.test.demo.read; import java.util.ArrayList; import java.util.List; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import com.alibaba.excel.context.AnalysisContext; import com.alibaba.excel.event.AnalysisEventListener; import com.alibaba.fastjson.JSON; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + /** * 模板的读取类 * @@ -18,7 +18,7 @@ import com.alibaba.fastjson.JSON; public class ConverterDataListener extends AnalysisEventListener { private static final Logger LOGGER = LoggerFactory.getLogger(ConverterDataListener.class); /** - * 每隔5条存储数据库,实际使用中可以3000条,然后清理list ,方便内存回收 + * 每隔5条存储数据库,实际使用中可以100条,然后清理list ,方便内存回收 */ private static final int BATCH_COUNT = 5; List list = new ArrayList(); diff --git a/src/test/java/com/alibaba/easyexcel/test/demo/read/DemoDataListener.java b/src/test/java/com/alibaba/easyexcel/test/demo/read/DemoDataListener.java index 6cc1ecef..4764f717 100644 --- a/src/test/java/com/alibaba/easyexcel/test/demo/read/DemoDataListener.java +++ b/src/test/java/com/alibaba/easyexcel/test/demo/read/DemoDataListener.java @@ -19,9 +19,9 @@ import org.slf4j.LoggerFactory; public class DemoDataListener extends AnalysisEventListener { private static final Logger LOGGER = LoggerFactory.getLogger(DemoDataListener.class); /** - * 每隔5条存储数据库,实际使用中可以3000条,然后清理list ,方便内存回收 + * 每隔5条存储数据库,实际使用中可以100条,然后清理list ,方便内存回收 */ - private static final int BATCH_COUNT = 3000; + private static final int BATCH_COUNT = 100; /** * 缓存的数据 */ diff --git a/src/test/java/com/alibaba/easyexcel/test/demo/read/DemoExceptionListener.java b/src/test/java/com/alibaba/easyexcel/test/demo/read/DemoExceptionListener.java index e4f9571a..b6dfdb4e 100644 --- a/src/test/java/com/alibaba/easyexcel/test/demo/read/DemoExceptionListener.java +++ b/src/test/java/com/alibaba/easyexcel/test/demo/read/DemoExceptionListener.java @@ -20,7 +20,7 @@ import com.alibaba.fastjson.JSON; public class DemoExceptionListener extends AnalysisEventListener { private static final Logger LOGGER = LoggerFactory.getLogger(DemoExceptionListener.class); /** - * 每隔5条存储数据库,实际使用中可以3000条,然后清理list ,方便内存回收 + * 每隔5条存储数据库,实际使用中可以100条,然后清理list ,方便内存回收 */ private static final int BATCH_COUNT = 5; List list = new ArrayList(); diff --git a/src/test/java/com/alibaba/easyexcel/test/demo/read/DemoHeadDataListener.java b/src/test/java/com/alibaba/easyexcel/test/demo/read/DemoHeadDataListener.java index 49800297..61bd834b 100644 --- a/src/test/java/com/alibaba/easyexcel/test/demo/read/DemoHeadDataListener.java +++ b/src/test/java/com/alibaba/easyexcel/test/demo/read/DemoHeadDataListener.java @@ -4,15 +4,14 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; -import org.junit.Assert; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import com.alibaba.excel.context.AnalysisContext; import com.alibaba.excel.event.AnalysisEventListener; import com.alibaba.excel.exception.ExcelDataConvertException; import com.alibaba.fastjson.JSON; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + /** * 读取头 * @@ -21,7 +20,7 @@ import com.alibaba.fastjson.JSON; public class DemoHeadDataListener extends AnalysisEventListener { private static final Logger LOGGER = LoggerFactory.getLogger(DemoHeadDataListener.class); /** - * 每隔5条存储数据库,实际使用中可以3000条,然后清理list ,方便内存回收 + * 每隔5条存储数据库,实际使用中可以100条,然后清理list ,方便内存回收 */ private static final int BATCH_COUNT = 5; List list = new ArrayList(); diff --git a/src/test/java/com/alibaba/easyexcel/test/demo/read/IndexOrNameDataListener.java b/src/test/java/com/alibaba/easyexcel/test/demo/read/IndexOrNameDataListener.java index 6c13d683..b8526ef1 100644 --- a/src/test/java/com/alibaba/easyexcel/test/demo/read/IndexOrNameDataListener.java +++ b/src/test/java/com/alibaba/easyexcel/test/demo/read/IndexOrNameDataListener.java @@ -3,13 +3,13 @@ package com.alibaba.easyexcel.test.demo.read; import java.util.ArrayList; import java.util.List; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import com.alibaba.excel.context.AnalysisContext; import com.alibaba.excel.event.AnalysisEventListener; import com.alibaba.fastjson.JSON; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + /** * 模板的读取类 * @@ -18,7 +18,7 @@ import com.alibaba.fastjson.JSON; public class IndexOrNameDataListener extends AnalysisEventListener { private static final Logger LOGGER = LoggerFactory.getLogger(IndexOrNameDataListener.class); /** - * 每隔5条存储数据库,实际使用中可以3000条,然后清理list ,方便内存回收 + * 每隔5条存储数据库,实际使用中可以100条,然后清理list ,方便内存回收 */ private static final int BATCH_COUNT = 5; List list = new ArrayList(); diff --git a/src/test/java/com/alibaba/easyexcel/test/demo/read/NoModelDataListener.java b/src/test/java/com/alibaba/easyexcel/test/demo/read/NoModelDataListener.java index a48d3fca..761b50f4 100644 --- a/src/test/java/com/alibaba/easyexcel/test/demo/read/NoModelDataListener.java +++ b/src/test/java/com/alibaba/easyexcel/test/demo/read/NoModelDataListener.java @@ -4,13 +4,13 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import com.alibaba.excel.context.AnalysisContext; import com.alibaba.excel.event.AnalysisEventListener; import com.alibaba.fastjson.JSON; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + /** * 直接用map接收数据 * @@ -19,7 +19,7 @@ import com.alibaba.fastjson.JSON; public class NoModelDataListener extends AnalysisEventListener> { private static final Logger LOGGER = LoggerFactory.getLogger(NoModelDataListener.class); /** - * 每隔5条存储数据库,实际使用中可以3000条,然后清理list ,方便内存回收 + * 每隔5条存储数据库,实际使用中可以100条,然后清理list ,方便内存回收 */ private static final int BATCH_COUNT = 5; List> list = new ArrayList>(); diff --git a/src/test/java/com/alibaba/easyexcel/test/demo/read/ReadTest.java b/src/test/java/com/alibaba/easyexcel/test/demo/read/ReadTest.java index ea447719..5fe67e4a 100644 --- a/src/test/java/com/alibaba/easyexcel/test/demo/read/ReadTest.java +++ b/src/test/java/com/alibaba/easyexcel/test/demo/read/ReadTest.java @@ -64,7 +64,7 @@ public class ReadTest { /** * 单次缓存的数据量 */ - public static final int BATCH_COUNT = 3000; + public static final int BATCH_COUNT = 100; /** *临时存储 */ diff --git a/src/test/java/com/alibaba/easyexcel/test/demo/web/UploadDataListener.java b/src/test/java/com/alibaba/easyexcel/test/demo/web/UploadDataListener.java index e61a5d65..936e2f17 100644 --- a/src/test/java/com/alibaba/easyexcel/test/demo/web/UploadDataListener.java +++ b/src/test/java/com/alibaba/easyexcel/test/demo/web/UploadDataListener.java @@ -20,7 +20,7 @@ public class UploadDataListener extends AnalysisEventListener { private static final Logger LOGGER = LoggerFactory.getLogger(com.alibaba.easyexcel.test.demo.read.DemoDataListener.class); /** - * 每隔5条存储数据库,实际使用中可以3000条,然后清理list ,方便内存回收 + * 每隔5条存储数据库,实际使用中可以100条,然后清理list ,方便内存回收 */ private static final int BATCH_COUNT = 5; List list = new ArrayList(); diff --git a/src/test/java/com/alibaba/easyexcel/test/temp/LockDataListener.java b/src/test/java/com/alibaba/easyexcel/test/temp/LockDataListener.java index bda277c6..1a7dffb5 100644 --- a/src/test/java/com/alibaba/easyexcel/test/temp/LockDataListener.java +++ b/src/test/java/com/alibaba/easyexcel/test/temp/LockDataListener.java @@ -19,7 +19,7 @@ import com.alibaba.fastjson.JSON; public class LockDataListener extends AnalysisEventListener { private static final Logger LOGGER = LoggerFactory.getLogger(DemoDataListener.class); /** - * 每隔5条存储数据库,实际使用中可以3000条,然后清理list ,方便内存回收 + * 每隔5条存储数据库,实际使用中可以100条,然后清理list ,方便内存回收 */ private static final int BATCH_COUNT = 5; List list = new ArrayList(); diff --git a/src/test/java/com/alibaba/easyexcel/test/temp/read/HDListener.java b/src/test/java/com/alibaba/easyexcel/test/temp/read/HDListener.java index 1c58e798..7835c51f 100644 --- a/src/test/java/com/alibaba/easyexcel/test/temp/read/HDListener.java +++ b/src/test/java/com/alibaba/easyexcel/test/temp/read/HDListener.java @@ -17,7 +17,7 @@ import com.alibaba.fastjson.JSON; public class HDListener extends AnalysisEventListener { private static final Logger LOGGER = LoggerFactory.getLogger(HDListener.class); /** - * 每隔5条存储数据库,实际使用中可以3000条,然后清理list ,方便内存回收 + * 每隔5条存储数据库,实际使用中可以100条,然后清理list ,方便内存回收 */ private static final int BATCH_COUNT = 5; diff --git a/src/test/java/com/alibaba/easyexcel/test/temp/read/HeadListener.java b/src/test/java/com/alibaba/easyexcel/test/temp/read/HeadListener.java index 31875fe2..c0cd96dd 100644 --- a/src/test/java/com/alibaba/easyexcel/test/temp/read/HeadListener.java +++ b/src/test/java/com/alibaba/easyexcel/test/temp/read/HeadListener.java @@ -17,7 +17,7 @@ import com.alibaba.fastjson.JSON; public class HeadListener extends AnalysisEventListener { private static final Logger LOGGER = LoggerFactory.getLogger(HeadListener.class); /** - * 每隔5条存储数据库,实际使用中可以3000条,然后清理list ,方便内存回收 + * 每隔5条存储数据库,实际使用中可以100条,然后清理list ,方便内存回收 */ private static final int BATCH_COUNT = 5; diff --git a/src/test/java/com/alibaba/easyexcel/test/temp/simple/HgListener.java b/src/test/java/com/alibaba/easyexcel/test/temp/simple/HgListener.java index b8250eae..f687416e 100644 --- a/src/test/java/com/alibaba/easyexcel/test/temp/simple/HgListener.java +++ b/src/test/java/com/alibaba/easyexcel/test/temp/simple/HgListener.java @@ -2,13 +2,13 @@ package com.alibaba.easyexcel.test.temp.simple; import java.util.Map; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import com.alibaba.excel.context.AnalysisContext; import com.alibaba.excel.event.AnalysisEventListener; import com.alibaba.fastjson.JSON; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + /** * 模板的读取类 * @@ -17,7 +17,7 @@ import com.alibaba.fastjson.JSON; public class HgListener extends AnalysisEventListener> { private static final Logger LOGGER = LoggerFactory.getLogger(HgListener.class); /** - * 每隔5条存储数据库,实际使用中可以3000条,然后清理list ,方便内存回收 + * 每隔5条存储数据库,实际使用中可以100条,然后清理list ,方便内存回收 */ private static final int BATCH_COUNT = 5; diff --git a/src/test/java/com/alibaba/easyexcel/test/temp/simple/RepeatListener.java b/src/test/java/com/alibaba/easyexcel/test/temp/simple/RepeatListener.java index aa54b396..46182803 100644 --- a/src/test/java/com/alibaba/easyexcel/test/temp/simple/RepeatListener.java +++ b/src/test/java/com/alibaba/easyexcel/test/temp/simple/RepeatListener.java @@ -20,7 +20,7 @@ import com.alibaba.fastjson.JSON; public class RepeatListener extends AnalysisEventListener { private static final Logger LOGGER = LoggerFactory.getLogger(DemoDataListener.class); /** - * 每隔5条存储数据库,实际使用中可以3000条,然后清理list ,方便内存回收 + * 每隔5条存储数据库,实际使用中可以100条,然后清理list ,方便内存回收 */ private static final int BATCH_COUNT = 5; List list = new ArrayList(); diff --git a/update.md b/update.md index 3e73f949..7e791d8d 100644 --- a/update.md +++ b/update.md @@ -1,3 +1,6 @@ +# 3.0.4 +* 调整读写默认大小,防止大批量写的时候可能会full gc + # 3.0.3 * 修复`HeadStyle`无效的bug From 04c9402e3fc1ee5599e162e5eef8ea4893ad7824 Mon Sep 17 00:00:00 2001 From: Jiaju Zhuang Date: Thu, 4 Nov 2021 21:51:13 +0800 Subject: [PATCH 2/5] =?UTF-8?q?*=20=E8=B0=83=E6=95=B4=E8=AF=BB=E5=86=99?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E5=A4=A7=E5=B0=8F=EF=BC=8C=E9=98=B2=E6=AD=A2?= =?UTF-8?q?=E5=A4=A7=E6=89=B9=E9=87=8F=E5=86=99=E7=9A=84=E6=97=B6=E5=80=99?= =?UTF-8?q?=E5=8F=AF=E8=83=BD=E4=BC=9Afull=20gc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/alibaba/excel/util/WorkBookUtil.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/alibaba/excel/util/WorkBookUtil.java b/src/main/java/com/alibaba/excel/util/WorkBookUtil.java index 71e1fd54..8fc7c210 100644 --- a/src/main/java/com/alibaba/excel/util/WorkBookUtil.java +++ b/src/main/java/com/alibaba/excel/util/WorkBookUtil.java @@ -26,8 +26,6 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook; */ public class WorkBookUtil { - public static final int ROW_ACCESS_WINDOW_SIZE = 500; - private WorkBookUtil() {} public static void createWorkBook(WriteWorkbookHolder writeWorkbookHolder) throws IOException { @@ -39,7 +37,7 @@ public class WorkBookUtil { if (writeWorkbookHolder.getInMemory()) { writeWorkbookHolder.setWorkbook(xssfWorkbook); } else { - writeWorkbookHolder.setWorkbook(new SXSSFWorkbook(xssfWorkbook, ROW_ACCESS_WINDOW_SIZE)); + writeWorkbookHolder.setWorkbook(new SXSSFWorkbook(xssfWorkbook)); } return; } @@ -47,7 +45,7 @@ public class WorkBookUtil { if (writeWorkbookHolder.getInMemory()) { workbook = new XSSFWorkbook(); } else { - workbook = new SXSSFWorkbook(ROW_ACCESS_WINDOW_SIZE); + workbook = new SXSSFWorkbook(); } writeWorkbookHolder.setCachedWorkbook(workbook); writeWorkbookHolder.setWorkbook(workbook); From 507a938884db0cd4f6186a3a38b9c92b40ffc3a9 Mon Sep 17 00:00:00 2001 From: Jiaju Zhuang Date: Fri, 5 Nov 2021 10:13:14 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9csv=E4=B8=8D=E9=9C=80?= =?UTF-8?q?=E8=A6=81=E6=A0=B7=E5=BC=8Fhandler?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../handler/DefaultWriteHandlerLoader.java | 27 +++- .../metadata/holder/AbstractWriteHolder.java | 33 +++-- .../metadata/holder/WriteSheetHolder.java | 4 + .../metadata/holder/WriteTableHolder.java | 3 + .../metadata/holder/WriteWorkbookHolder.java | 4 + .../easyexcel/test/temp/large/LargeData.java | 4 +- .../test/temp/large/TempLargeDataTest.java | 128 +++++++++++++++++- 7 files changed, 181 insertions(+), 22 deletions(-) diff --git a/src/main/java/com/alibaba/excel/write/handler/DefaultWriteHandlerLoader.java b/src/main/java/com/alibaba/excel/write/handler/DefaultWriteHandlerLoader.java index 7fda3908..4d24d48f 100644 --- a/src/main/java/com/alibaba/excel/write/handler/DefaultWriteHandlerLoader.java +++ b/src/main/java/com/alibaba/excel/write/handler/DefaultWriteHandlerLoader.java @@ -3,6 +3,7 @@ package com.alibaba.excel.write.handler; import java.util.ArrayList; import java.util.List; +import com.alibaba.excel.support.ExcelTypeEnum; import com.alibaba.excel.write.handler.impl.DefaultRowWriteHandler; import com.alibaba.excel.write.handler.impl.DimensionWorkbookWriteHandler; import com.alibaba.excel.write.handler.impl.FillStyleCellWriteHandler; @@ -28,12 +29,30 @@ public class DefaultWriteHandlerLoader { * * @return */ - public static List loadDefaultHandler(Boolean useDefaultStyle) { + public static List loadDefaultHandler(Boolean useDefaultStyle, ExcelTypeEnum excelType) { List handlerList = new ArrayList<>(); - if (useDefaultStyle) { - handlerList.add(new DefaultStyle()); + switch (excelType) { + case XLSX: + handlerList.add(new DimensionWorkbookWriteHandler()); + handlerList.add(new DefaultRowWriteHandler()); + handlerList.add(new FillStyleCellWriteHandler()); + if (useDefaultStyle) { + handlerList.add(new DefaultStyle()); + } + break; + case XLS: + handlerList.add(new DefaultRowWriteHandler()); + handlerList.add(new FillStyleCellWriteHandler()); + if (useDefaultStyle) { + handlerList.add(new DefaultStyle()); + } + break; + case CSV: + handlerList.add(new DefaultRowWriteHandler()); + break; + default: + break; } - handlerList.addAll(DEFAULT_WRITE_HANDLER_LIST); return handlerList; } diff --git a/src/main/java/com/alibaba/excel/write/metadata/holder/AbstractWriteHolder.java b/src/main/java/com/alibaba/excel/write/metadata/holder/AbstractWriteHolder.java index 016191ae..b6907e42 100644 --- a/src/main/java/com/alibaba/excel/write/metadata/holder/AbstractWriteHolder.java +++ b/src/main/java/com/alibaba/excel/write/metadata/holder/AbstractWriteHolder.java @@ -203,6 +203,21 @@ public abstract class AbstractWriteHolder extends AbstractHolder implements Writ // Initialization property this.excelWriteHeadProperty = new ExcelWriteHeadProperty(this, getClazz(), getHead()); + // Set converterMap + if (parentAbstractWriteHolder == null) { + setConverterMap(DefaultConverterLoader.loadDefaultWriteConverter()); + } else { + setConverterMap(new HashMap<>(parentAbstractWriteHolder.getConverterMap())); + } + if (writeBasicParameter.getCustomConverterList() != null + && !writeBasicParameter.getCustomConverterList().isEmpty()) { + for (Converter converter : writeBasicParameter.getCustomConverterList()) { + getConverterMap().put(ConverterKeyBuild.buildKey(converter.supportJavaTypeKey()), converter); + } + } + } + + protected void initHandler(WriteBasicParameter writeBasicParameter, AbstractWriteHolder parentAbstractWriteHolder) { // Set writeHandlerMap List handlerList = new ArrayList<>(); @@ -220,22 +235,12 @@ public abstract class AbstractWriteHolder extends AbstractHolder implements Writ handlerList.addAll(parentAbstractWriteHolder.getWriteHandlerList()); } } else { - handlerList.addAll(DefaultWriteHandlerLoader.loadDefaultHandler(useDefaultStyle)); - } - sortAndClearUpHandler(handlerList, false); - - // Set converterMap - if (parentAbstractWriteHolder == null) { - setConverterMap(DefaultConverterLoader.loadDefaultWriteConverter()); - } else { - setConverterMap(new HashMap<>(parentAbstractWriteHolder.getConverterMap())); - } - if (writeBasicParameter.getCustomConverterList() != null - && !writeBasicParameter.getCustomConverterList().isEmpty()) { - for (Converter converter : writeBasicParameter.getCustomConverterList()) { - getConverterMap().put(ConverterKeyBuild.buildKey(converter.supportJavaTypeKey()), converter); + if (this instanceof WriteWorkbookHolder) { + handlerList.addAll(DefaultWriteHandlerLoader.loadDefaultHandler(useDefaultStyle, + ((WriteWorkbookHolder)this).getExcelType())); } } + sortAndClearUpHandler(handlerList, false); } protected void initAnnotationConfig(List handlerList, WriteBasicParameter writeBasicParameter) { diff --git a/src/main/java/com/alibaba/excel/write/metadata/holder/WriteSheetHolder.java b/src/main/java/com/alibaba/excel/write/metadata/holder/WriteSheetHolder.java index ffc6f759..3fa493ff 100644 --- a/src/main/java/com/alibaba/excel/write/metadata/holder/WriteSheetHolder.java +++ b/src/main/java/com/alibaba/excel/write/metadata/holder/WriteSheetHolder.java @@ -80,6 +80,10 @@ public class WriteSheetHolder extends AbstractWriteHolder { public WriteSheetHolder(WriteSheet writeSheet, WriteWorkbookHolder writeWorkbookHolder) { super(writeSheet, writeWorkbookHolder); + + // init handler + initHandler(writeSheet, writeWorkbookHolder); + this.writeSheet = writeSheet; if (writeSheet.getSheetNo() == null && StringUtils.isEmpty(writeSheet.getSheetName())) { this.sheetNo = 0; diff --git a/src/main/java/com/alibaba/excel/write/metadata/holder/WriteTableHolder.java b/src/main/java/com/alibaba/excel/write/metadata/holder/WriteTableHolder.java index 3a46e784..d72544be 100644 --- a/src/main/java/com/alibaba/excel/write/metadata/holder/WriteTableHolder.java +++ b/src/main/java/com/alibaba/excel/write/metadata/holder/WriteTableHolder.java @@ -34,6 +34,9 @@ public class WriteTableHolder extends AbstractWriteHolder { this.parentWriteSheetHolder = writeSheetHolder; this.tableNo = writeTable.getTableNo(); this.writeTable = writeTable; + + // init handler + initHandler(writeTable, writeSheetHolder); } @Override 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 1353ddc4..ec8e3349 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 @@ -199,6 +199,10 @@ public class WriteWorkbookHolder extends AbstractWriteHolder { } else { this.excelType = writeWorkbook.getExcelType(); } + + // init handler + initHandler(writeWorkbook, null); + try { copyTemplate(); } catch (IOException e) { diff --git a/src/test/java/com/alibaba/easyexcel/test/temp/large/LargeData.java b/src/test/java/com/alibaba/easyexcel/test/temp/large/LargeData.java index 59444b38..7885a8d2 100644 --- a/src/test/java/com/alibaba/easyexcel/test/temp/large/LargeData.java +++ b/src/test/java/com/alibaba/easyexcel/test/temp/large/LargeData.java @@ -1,8 +1,8 @@ package com.alibaba.easyexcel.test.temp.large; -import lombok.Builder; import lombok.EqualsAndHashCode; import lombok.Getter; +import lombok.NoArgsConstructor; import lombok.Setter; /** @@ -11,7 +11,7 @@ import lombok.Setter; @Getter @Setter @EqualsAndHashCode -@Builder +@NoArgsConstructor public class LargeData { private String str1; diff --git a/src/test/java/com/alibaba/easyexcel/test/temp/large/TempLargeDataTest.java b/src/test/java/com/alibaba/easyexcel/test/temp/large/TempLargeDataTest.java index 7f4a6717..1d97027b 100644 --- a/src/test/java/com/alibaba/easyexcel/test/temp/large/TempLargeDataTest.java +++ b/src/test/java/com/alibaba/easyexcel/test/temp/large/TempLargeDataTest.java @@ -2,13 +2,25 @@ package com.alibaba.easyexcel.test.temp.large; import java.io.File; import java.io.FileInputStream; +import java.io.FileOutputStream; import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.IntStream; import com.alibaba.easyexcel.test.core.large.LargeDataTest; import com.alibaba.easyexcel.test.util.TestFileUtil; import com.alibaba.excel.EasyExcel; +import com.alibaba.excel.ExcelWriter; +import com.alibaba.excel.write.metadata.WriteSheet; import org.apache.poi.openxml4j.util.ZipSecureFile; +import org.apache.poi.xssf.streaming.SXSSFCell; +import org.apache.poi.xssf.streaming.SXSSFRow; +import org.apache.poi.xssf.streaming.SXSSFSheet; +import org.apache.poi.xssf.streaming.SXSSFWorkbook; +import org.junit.Assert; +import org.junit.BeforeClass; import org.junit.Ignore; import org.junit.Test; import org.slf4j.Logger; @@ -21,6 +33,24 @@ import org.slf4j.LoggerFactory; public class TempLargeDataTest { private static final Logger LOGGER = LoggerFactory.getLogger(LargeDataTest.class); + private int i = 0; + + private static File fileFill07; + private static File template07; + private static File fileCsv; + private static File fileWrite07; + private static File fileWriteTemp07; + private static File fileWritePoi07; + + @BeforeClass + public static void init() { + fileFill07 = TestFileUtil.createNewFile("largefill07.xlsx"); + fileWrite07 = TestFileUtil.createNewFile("large" + File.separator + "fileWrite07.xlsx"); + fileWriteTemp07 = TestFileUtil.createNewFile("large" + File.separator + "fileWriteTemp07.xlsx"); + fileWritePoi07 = TestFileUtil.createNewFile("large" + File.separator + "fileWritePoi07.xlsx"); + template07 = TestFileUtil.readFile("large" + File.separator + "fill.xlsx"); + fileCsv = TestFileUtil.createNewFile("largefileCsv.csv"); + } @Test public void read() throws Exception { @@ -47,9 +77,103 @@ public class TempLargeDataTest { long start = System.currentTimeMillis(); EasyExcel.read( - new File("/Users/zhuangjiaju/IdeaProjects/easyexcel/target/test-classes/large1617887262709.xlsx"), - new NoModelLargeDataListener()) + new File("/Users/zhuangjiaju/IdeaProjects/easyexcel/target/test-classes/large1617887262709.xlsx"), + new NoModelLargeDataListener()) .sheet().doRead(); LOGGER.info("Large data total time spent:{}", System.currentTimeMillis() - start); } + + @Test + public void t04Write() throws Exception { + ExcelWriter excelWriter = EasyExcel.write(fileWriteTemp07, + com.alibaba.easyexcel.test.core.large.LargeData.class).build(); + WriteSheet writeSheet = EasyExcel.writerSheet().build(); + for (int j = 0; j < 2; j++) { + excelWriter.write(data(), writeSheet); + } + excelWriter.finish(); + + long start = System.currentTimeMillis(); + excelWriter = EasyExcel.write(fileWrite07, com.alibaba.easyexcel.test.core.large.LargeData.class).build(); + writeSheet = EasyExcel.writerSheet().build(); + for (int j = 0; j < 5000; j++) { + excelWriter.write(data(), writeSheet); + LOGGER.info("{} write success.", j); + } + excelWriter.finish(); + long cost = System.currentTimeMillis() - start; + LOGGER.info("write cost:{}", cost); + start = System.currentTimeMillis(); + try (FileOutputStream fileOutputStream = new FileOutputStream(fileWritePoi07)) { + SXSSFWorkbook workbook = new SXSSFWorkbook(); + SXSSFSheet sheet = workbook.createSheet("sheet1"); + for (int i = 0; i < 100 * 5000; i++) { + SXSSFRow row = sheet.createRow(i); + for (int j = 0; j < 25; j++) { + SXSSFCell cell = row.createCell(j); + cell.setCellValue("str-" + j + "-" + i); + } + if (i % 5000 == 0) { + LOGGER.info("{} write success.", i); + } + } + workbook.write(fileOutputStream); + workbook.dispose(); + workbook.close(); + } + long costPoi = System.currentTimeMillis() - start; + LOGGER.info("poi write cost:{}", System.currentTimeMillis() - start); + LOGGER.info("{} vs {}", cost, costPoi); + Assert.assertTrue(costPoi * 2 > cost); + } + + @Test + public void t04WriteExcel() throws Exception { + IntStream.rangeClosed(0, 100).forEach(index -> { + ExcelWriter excelWriter = EasyExcel.write(fileWriteTemp07, + com.alibaba.easyexcel.test.core.large.LargeData.class).build(); + WriteSheet writeSheet = EasyExcel.writerSheet().build(); + for (int j = 0; j < 2; j++) { + excelWriter.write(data(), writeSheet); + } + excelWriter.finish(); + LOGGER.info("{} 完成", index); + }); + } + + private List data() { + List list = new ArrayList<>(); + + int size = i + 100; + for (; i < size; i++) { + LargeData largeData = new LargeData(); + list.add(largeData); + largeData.setStr1("str1-" + i); + largeData.setStr2("str2-" + i); + largeData.setStr3("str3-" + i); + largeData.setStr4("str4-" + i); + largeData.setStr5("str5-" + i); + largeData.setStr6("str6-" + i); + largeData.setStr7("str7-" + i); + largeData.setStr8("str8-" + i); + largeData.setStr9("str9-" + i); + largeData.setStr10("str10-" + i); + largeData.setStr11("str11-" + i); + largeData.setStr12("str12-" + i); + largeData.setStr13("str13-" + i); + largeData.setStr14("str14-" + i); + largeData.setStr15("str15-" + i); + largeData.setStr16("str16-" + i); + largeData.setStr17("str17-" + i); + largeData.setStr18("str18-" + i); + largeData.setStr19("str19-" + i); + largeData.setStr20("str20-" + i); + largeData.setStr21("str21-" + i); + largeData.setStr22("str22-" + i); + largeData.setStr23("str23-" + i); + largeData.setStr24("str24-" + i); + largeData.setStr25("str25-" + i); + } + return list; + } } From fc59b8601fdda770f2328f35cc9ebd68ac7bab67 Mon Sep 17 00:00:00 2001 From: Jiaju Zhuang Date: Tue, 9 Nov 2021 20:01:54 +0800 Subject: [PATCH 4/5] =?UTF-8?q?*=20`fill`=E7=9A=84=E6=83=85=E5=86=B5?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=20`afterRowDispose`=E4=BA=8B=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../write/style/ContentLoopMerge.java | 2 +- .../executor/ExcelWriteFillExecutor.java | 28 ++++-- .../excel/write/handler/RowWriteHandler.java | 6 +- .../excel/write/merge/LoopMergeStrategy.java | 21 ++-- .../fill/annotation/FillAnnotationData.java | 36 +++++++ .../annotation/FillAnnotationDataTest.java | 92 ++++++++++++++++++ .../test/temp/large/TempLargeDataTest.java | 47 ++++++++- src/test/resources/fill/annotation.xls | Bin 0 -> 26624 bytes src/test/resources/fill/annotation.xlsx | Bin 0 -> 10692 bytes update.md | 1 + 10 files changed, 210 insertions(+), 23 deletions(-) create mode 100644 src/test/java/com/alibaba/easyexcel/test/core/fill/annotation/FillAnnotationData.java create mode 100644 src/test/java/com/alibaba/easyexcel/test/core/fill/annotation/FillAnnotationDataTest.java create mode 100644 src/test/resources/fill/annotation.xls create mode 100644 src/test/resources/fill/annotation.xlsx diff --git a/src/main/java/com/alibaba/excel/annotation/write/style/ContentLoopMerge.java b/src/main/java/com/alibaba/excel/annotation/write/style/ContentLoopMerge.java index af7bcecf..60654fe5 100644 --- a/src/main/java/com/alibaba/excel/annotation/write/style/ContentLoopMerge.java +++ b/src/main/java/com/alibaba/excel/annotation/write/style/ContentLoopMerge.java @@ -20,7 +20,7 @@ public @interface ContentLoopMerge { * * @return */ - int eachRow() default -1; + int eachRow() default 1; /** * Extend column diff --git a/src/main/java/com/alibaba/excel/write/executor/ExcelWriteFillExecutor.java b/src/main/java/com/alibaba/excel/write/executor/ExcelWriteFillExecutor.java index af90d8d5..6779e875 100644 --- a/src/main/java/com/alibaba/excel/write/executor/ExcelWriteFillExecutor.java +++ b/src/main/java/com/alibaba/excel/write/executor/ExcelWriteFillExecutor.java @@ -200,6 +200,9 @@ public class ExcelWriteFillExecutor extends AbstractExcelWriteExecutor { } Set dataKeySet = new HashSet<>(dataMap.keySet()); + RowWriteHandlerContext rowWriteHandlerContext = WriteHandlerUtils.createRowWriteHandlerContext(writeContext, + null, relativeRowIndex, Boolean.FALSE); + for (AnalysisCell analysisCell : analysisCellList) { CellWriteHandlerContext cellWriteHandlerContext = WriteHandlerUtils.createCellWriteHandlerContext( writeContext, null, analysisCell.getRowIndex(), null, analysisCell.getColumnIndex(), @@ -215,7 +218,7 @@ public class ExcelWriteFillExecutor extends AbstractExcelWriteExecutor { writeContext.currentWriteHolder().excelWriteHeadProperty().getHeadClazz(), variable); cellWriteHandlerContext.setExcelContentProperty(excelContentProperty); - createCell(analysisCell, fillConfig, cellWriteHandlerContext); + createCell(analysisCell, fillConfig, cellWriteHandlerContext, rowWriteHandlerContext); cellWriteHandlerContext.setOriginalValue(value); cellWriteHandlerContext.setOriginalFieldClass(FieldUtils.getFieldClass(dataMap, variable, value)); @@ -236,7 +239,7 @@ public class ExcelWriteFillExecutor extends AbstractExcelWriteExecutor { cellWriteHandlerContext.setExcelContentProperty(ExcelContentProperty.EMPTY); cellWriteHandlerContext.setIgnoreFillStyle(Boolean.TRUE); - createCell(analysisCell, fillConfig, cellWriteHandlerContext); + createCell(analysisCell, fillConfig, cellWriteHandlerContext, rowWriteHandlerContext); Cell cell = cellWriteHandlerContext.getCell(); for (String variable : analysisCell.getVariableList()) { @@ -288,6 +291,11 @@ public class ExcelWriteFillExecutor extends AbstractExcelWriteExecutor { } WriteHandlerUtils.afterCellDispose(cellWriteHandlerContext); } + + // In the case of the fill line may be called many times + if (rowWriteHandlerContext.getRow() != null) { + WriteHandlerUtils.afterRowDispose(rowWriteHandlerContext); + } } private Integer getRelativeRowIndex() { @@ -302,13 +310,16 @@ public class ExcelWriteFillExecutor extends AbstractExcelWriteExecutor { } private void createCell(AnalysisCell analysisCell, FillConfig fillConfig, - CellWriteHandlerContext cellWriteHandlerContext) { + CellWriteHandlerContext cellWriteHandlerContext, RowWriteHandlerContext rowWriteHandlerContext) { Sheet cachedSheet = writeContext.writeSheetHolder().getCachedSheet(); if (WriteTemplateAnalysisCellTypeEnum.COMMON.equals(analysisCell.getCellType())) { Row row = cachedSheet.getRow(analysisCell.getRowIndex()); cellWriteHandlerContext.setRow(row); Cell cell = row.getCell(analysisCell.getColumnIndex()); cellWriteHandlerContext.setCell(cell); + rowWriteHandlerContext.setRow(row); + rowWriteHandlerContext.setRowIndex(analysisCell.getRowIndex()); + return; } Sheet sheet = writeContext.writeSheetHolder().getSheet(); @@ -345,7 +356,8 @@ public class ExcelWriteFillExecutor extends AbstractExcelWriteExecutor { throw new ExcelGenerateException("The wrong direction."); } - Row row = createRowIfNecessary(sheet, cachedSheet, lastRowIndex, fillConfig, analysisCell, isOriginalCell); + Row row = createRowIfNecessary(sheet, cachedSheet, lastRowIndex, fillConfig, analysisCell, isOriginalCell, + rowWriteHandlerContext); cellWriteHandlerContext.setRow(row); cellWriteHandlerContext.setRowIndex(lastRowIndex); @@ -375,16 +387,17 @@ public class ExcelWriteFillExecutor extends AbstractExcelWriteExecutor { } private Row createRowIfNecessary(Sheet sheet, Sheet cachedSheet, Integer lastRowIndex, FillConfig fillConfig, - AnalysisCell analysisCell, boolean isOriginalCell) { + AnalysisCell analysisCell, boolean isOriginalCell, RowWriteHandlerContext rowWriteHandlerContext) { + rowWriteHandlerContext.setRowIndex(lastRowIndex); Row row = sheet.getRow(lastRowIndex); if (row != null) { checkRowHeight(analysisCell, fillConfig, isOriginalCell, row); + rowWriteHandlerContext.setRow(row); return row; } row = cachedSheet.getRow(lastRowIndex); if (row == null) { - RowWriteHandlerContext rowWriteHandlerContext = WriteHandlerUtils.createRowWriteHandlerContext(writeContext, - lastRowIndex, null, Boolean.FALSE); + rowWriteHandlerContext.setRowIndex(lastRowIndex); WriteHandlerUtils.beforeRowCreate(rowWriteHandlerContext); if (fillConfig.getForceNewRow()) { @@ -405,6 +418,7 @@ public class ExcelWriteFillExecutor extends AbstractExcelWriteExecutor { WriteHandlerUtils.afterRowCreate(rowWriteHandlerContext); } else { checkRowHeight(analysisCell, fillConfig, isOriginalCell, row); + rowWriteHandlerContext.setRow(row); } return row; } diff --git a/src/main/java/com/alibaba/excel/write/handler/RowWriteHandler.java b/src/main/java/com/alibaba/excel/write/handler/RowWriteHandler.java index afef0c97..c3dc708b 100644 --- a/src/main/java/com/alibaba/excel/write/handler/RowWriteHandler.java +++ b/src/main/java/com/alibaba/excel/write/handler/RowWriteHandler.java @@ -58,7 +58,8 @@ public interface RowWriteHandler extends WriteHandler { Integer relativeRowIndex, Boolean isHead) {} /** - * Called after all operations on the row have been completed.This method is not called when fill the data. + * Called after all operations on the row have been completed. + * In the case of the fill , may be called many times. * * @param context */ @@ -68,7 +69,8 @@ public interface RowWriteHandler extends WriteHandler { } /** - * Called after all operations on the row have been completed.This method is not called when fill the data. + * Called after all operations on the row have been completed. + * In the case of the fill , may be called many times. * * @param writeSheetHolder * @param writeTableHolder Nullable.It is null without using table writes. diff --git a/src/main/java/com/alibaba/excel/write/merge/LoopMergeStrategy.java b/src/main/java/com/alibaba/excel/write/merge/LoopMergeStrategy.java index 13ebe3cb..961db51f 100644 --- a/src/main/java/com/alibaba/excel/write/merge/LoopMergeStrategy.java +++ b/src/main/java/com/alibaba/excel/write/merge/LoopMergeStrategy.java @@ -1,13 +1,10 @@ package com.alibaba.excel.write.merge; -import org.apache.poi.ss.usermodel.Row; -import org.apache.poi.ss.util.CellRangeAddress; - import com.alibaba.excel.metadata.property.LoopMergeProperty; -import com.alibaba.excel.write.handler.AbstractRowWriteHandler; import com.alibaba.excel.write.handler.RowWriteHandler; -import com.alibaba.excel.write.metadata.holder.WriteSheetHolder; -import com.alibaba.excel.write.metadata.holder.WriteTableHolder; +import com.alibaba.excel.write.handler.context.RowWriteHandlerContext; + +import org.apache.poi.ss.util.CellRangeAddress; /** * The regions of the loop merge @@ -55,15 +52,15 @@ public class LoopMergeStrategy implements RowWriteHandler { } @Override - public void afterRowDispose(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, Row row, - Integer relativeRowIndex, Boolean isHead) { - if (isHead) { + public void afterRowDispose(RowWriteHandlerContext context) { + if (context.getHead() || context.getRelativeRowIndex() == null) { return; } - if (relativeRowIndex % eachRow == 0) { - CellRangeAddress cellRangeAddress = new CellRangeAddress(row.getRowNum(), row.getRowNum() + eachRow - 1, + if (context.getRelativeRowIndex() % eachRow == 0) { + CellRangeAddress cellRangeAddress = new CellRangeAddress(context.getRowIndex(), + context.getRowIndex() + eachRow - 1, columnIndex, columnIndex + columnExtend - 1); - writeSheetHolder.getSheet().addMergedRegionUnsafe(cellRangeAddress); + context.getWriteSheetHolder().getSheet().addMergedRegionUnsafe(cellRangeAddress); } } diff --git a/src/test/java/com/alibaba/easyexcel/test/core/fill/annotation/FillAnnotationData.java b/src/test/java/com/alibaba/easyexcel/test/core/fill/annotation/FillAnnotationData.java new file mode 100644 index 00000000..bc4c2483 --- /dev/null +++ b/src/test/java/com/alibaba/easyexcel/test/core/fill/annotation/FillAnnotationData.java @@ -0,0 +1,36 @@ +package com.alibaba.easyexcel.test.core.fill.annotation; + +import java.util.Date; + +import com.alibaba.excel.annotation.ExcelProperty; +import com.alibaba.excel.annotation.format.DateTimeFormat; +import com.alibaba.excel.annotation.format.NumberFormat; +import com.alibaba.excel.annotation.write.style.ContentLoopMerge; +import com.alibaba.excel.annotation.write.style.ContentRowHeight; + +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.Setter; + +/** + * @author Jiaju Zhuang + */ +@Getter +@Setter +@EqualsAndHashCode +@ContentRowHeight(100) +public class FillAnnotationData { + @ExcelProperty("日期") + @DateTimeFormat("yyyy年MM月dd日HH时mm分ss秒") + private Date date; + + @ExcelProperty(value = "数字") + @NumberFormat("#.##%") + private Double number; + + @ContentLoopMerge(columnExtend = 2) + @ExcelProperty("字符串1") + private String string1; + @ExcelProperty("字符串2") + private String string2; +} diff --git a/src/test/java/com/alibaba/easyexcel/test/core/fill/annotation/FillAnnotationDataTest.java b/src/test/java/com/alibaba/easyexcel/test/core/fill/annotation/FillAnnotationDataTest.java new file mode 100644 index 00000000..93680d69 --- /dev/null +++ b/src/test/java/com/alibaba/easyexcel/test/core/fill/annotation/FillAnnotationDataTest.java @@ -0,0 +1,92 @@ +package com.alibaba.easyexcel.test.core.fill.annotation; + +import java.io.File; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import com.alibaba.easyexcel.test.util.TestFileUtil; +import com.alibaba.excel.EasyExcel; +import com.alibaba.excel.util.DateUtils; + +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.ss.usermodel.WorkbookFactory; +import org.apache.poi.ss.util.CellRangeAddress; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.FixMethodOrder; +import org.junit.Test; +import org.junit.runners.MethodSorters; + +/** + * @author Jiaju Zhuang + */ +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class FillAnnotationDataTest { + + private static File file07; + private static File file03; + private static File fileTemplate07; + private static File fileTemplate03; + + @BeforeClass + public static void init() { + file07 = TestFileUtil.createNewFile("fillAnnotation07.xlsx"); + file03 = TestFileUtil.createNewFile("fillAnnotation03.xls"); + fileTemplate07 = TestFileUtil.readFile("fill" + File.separator + "annotation.xlsx"); + fileTemplate03 = TestFileUtil.readFile("fill" + File.separator + "annotation.xls"); + } + + @Test + public void t01ReadAndWrite07() throws Exception { + readAndWrite(file07, fileTemplate07); + } + + @Test + public void t02ReadAndWrite03() throws Exception { + readAndWrite(file03, fileTemplate03); + } + + private void readAndWrite(File file, File fileTemplate) throws Exception { + EasyExcel.write().file(file).head(FillAnnotationData.class).withTemplate(fileTemplate).sheet().doFill(data()); + + Workbook workbook = WorkbookFactory.create(file); + Sheet sheet = workbook.getSheetAt(0); + + Row row1 = sheet.getRow(1); + Assert.assertEquals(2000, row1.getHeight(), 0); + Cell cell10 = row1.getCell(0); + Date date = cell10.getDateCellValue(); + Assert.assertEquals(DateUtils.parseDate("2020-01-01 01:01:01").getTime(), date.getTime()); + String dataFormatString = cell10.getCellStyle().getDataFormatString(); + Assert.assertEquals("yyyy年MM月dd日HH时mm分ss秒", dataFormatString); + Cell cell11 = row1.getCell(1); + Assert.assertEquals(99.99, cell11.getNumericCellValue(), 2); + boolean hasMerge = false; + for (CellRangeAddress mergedRegion : sheet.getMergedRegions()) { + if (mergedRegion.getFirstRow() == 1 && mergedRegion.getLastRow() == 1 + && mergedRegion.getFirstColumn() == 2 && mergedRegion.getLastColumn() == 3) { + hasMerge = true; + } + } + Assert.assertTrue(hasMerge); + } + + private List data() throws Exception { + List list = new ArrayList<>(); + FillAnnotationData data = new FillAnnotationData(); + data.setDate(DateUtils.parseDate("2020-01-01 01:01:01")); + data.setNumber(99.99); + data.setString1("string1"); + data.setString2("string2"); + list.add(data); + list.add(data); + list.add(data); + list.add(data); + list.add(data); + return list; + } +} diff --git a/src/test/java/com/alibaba/easyexcel/test/temp/large/TempLargeDataTest.java b/src/test/java/com/alibaba/easyexcel/test/temp/large/TempLargeDataTest.java index 1d97027b..934b62f5 100644 --- a/src/test/java/com/alibaba/easyexcel/test/temp/large/TempLargeDataTest.java +++ b/src/test/java/com/alibaba/easyexcel/test/temp/large/TempLargeDataTest.java @@ -133,7 +133,7 @@ public class TempLargeDataTest { ExcelWriter excelWriter = EasyExcel.write(fileWriteTemp07, com.alibaba.easyexcel.test.core.large.LargeData.class).build(); WriteSheet writeSheet = EasyExcel.writerSheet().build(); - for (int j = 0; j < 2; j++) { + for (int j = 0; j < 5000; j++) { excelWriter.write(data(), writeSheet); } excelWriter.finish(); @@ -141,6 +141,51 @@ public class TempLargeDataTest { }); } + @Test + public void t04WriteExcelNo() throws Exception { + IntStream.rangeClosed(0, 10000).forEach(index -> { + ExcelWriter excelWriter = EasyExcel.write(fileWriteTemp07, + com.alibaba.easyexcel.test.core.large.LargeData.class).build(); + WriteSheet writeSheet = EasyExcel.writerSheet().build(); + for (int j = 0; j < 50; j++) { + excelWriter.write(data(), writeSheet); + } + excelWriter.finish(); + LOGGER.info("{} 完成", index); + }); + } + + @Test + public void t04WriteExcelPoi() throws Exception { + IntStream.rangeClosed(0, 10000).forEach(index -> { + try (FileOutputStream fileOutputStream = new FileOutputStream(fileWritePoi07)) { + SXSSFWorkbook workbook = new SXSSFWorkbook(500); + //workbook.setCompressTempFiles(true); + SXSSFSheet sheet = workbook.createSheet("sheet1"); + for (int i = 0; i < 100 * 50; i++) { + SXSSFRow row = sheet.createRow(i); + for (int j = 0; j < 25; j++) { + String str = "str-" + j + "-" + i; + //if (i + 10000 == j) { + SXSSFCell cell = row.createCell(j); + cell.setCellValue(str); + //System.out.println(str); + //} + } + if (i % 5000 == 0) { + LOGGER.info("{} write success.", i); + } + } + workbook.write(fileOutputStream); + workbook.dispose(); + workbook.close(); + } catch (Exception e) { + e.printStackTrace(); + } + LOGGER.info("{} 完成", index); + }); + } + private List data() { List list = new ArrayList<>(); diff --git a/src/test/resources/fill/annotation.xls b/src/test/resources/fill/annotation.xls new file mode 100644 index 0000000000000000000000000000000000000000..8fd19c5a7fa7300facc2a11f4f84c04ff6606b40 GIT binary patch literal 26624 zcmeHQ2UHYEx2_om7z9KRi3%eEk|ZN2A{bCm5XCjE0Z@kUi=com{>p+1Dn`UCsEdGc zMTJ#SbQNWd=$bLRigC@Z%9@yWZx21wGt-0e-oNL)ch0n@db(~^efQR_Tj_Q+p8H+@ zkHTGMcZuB9ov4upkrvTl&^hqzPRCmjNEeAPO8>gSGmuo*|04}(@u49#)XDc@XEdt_ zmuT<_xeLELc^D()9)wY3B56ZNX#BY3q?DwXR6$rwO#C>ZU`UEES?~{CJt-NYI4Hwm zFg!nw2H^lrjTFFLpO{k88Bq7u)O`n)_W*VGBL+m2@s^W0@w2NBAP^`!oEt#pTS(ol zsC!GebI4w*%yo+5MhwYK$j>LaXzpY-;d17W92|!9SN|cpGW=fvUzDN9S6TizkkE%k zPA3ir=m$`BGV=43&~Jhc*z#k2^;z(dZm5LbO$og_E1g69S>${L@_4e+3D6bwgZZ_T z6pG%Bc=^SWxMZIBtwdC?!@Y)h}Kp|EoRvnx=ba0KZ_Z?+NM@HFO@Y=)J*;Xcf zWVkSTv}`6TqDk6GGda7;;y@gsI)YeM^10;D8nb#62OOg#P!tCNEm>o9lpRGFW$)Wa zu^x+Yr(St z5P@7CStKgsAJ8B0dM9c{{fcjg1u8mf;ySwQ~Fn=Z&yO! zs)Syugr2X2zC#K9XC?HtO6c>I(3Q!f48L3n&N?OZ=E_s71ZS5L`Y#k+6UJ1kz5W(A z7i}l701?yQ%F?xH`Xw?D9xdtoEoAB1G#wtqIG3;o6FmjG9KJ4{Ut&LEJJC^~i|xdS zre7jagmjn4qX~l|TfH=4WM-r5(>TlY^;c@I)F!+Ylzv)E=rJ*eEDu={-d>6hV;-x1 z43*FgX!<1*36C%+iu;QujJ#~}Xu>4GMsG>uNc6Lfk_UStl^^66%PE#06fU8Q>m}|N zFlUPC5}aQt97Xy(CG>qt=wd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T5Dhf*p5^*KuUx*RML*(JmS{;N7|7OVyN2j|8_ev3`O<$ z4{4wQ{CYanU@6N0yWSt!>)(6`i)*!Q37 zdQc-Fpf4Z}0v@)Q2myTrX%Nt7PzZtc5s3Hkt*G)qR{CoJz?c^g8;XySNgv&%j~+w^ zG9oxS7cld_;@bLM&#AIlJ{p3UCm{lO#(MZez#@GcfFW66AuikE|msU8c=CKr2&-&R2ooeK&1hd22>hQ zX+Wg`l?MKIHGq3v+}q;*mj?mQU*Y?G+$Q6m9?!htSw7s$<31ht?0Ak0Pk-UQULOL! z`^UX8ecBH9_viz__x$)LlJHLg;h(_4_xkN1;6~XJf&c>k-yv4;+W~?#1RDsp5IRDz zgMjG{@aqV{2?GAzKl}@ME)ZNHVEPvb_^Y~_uYqv*Tn|6k6OcfX2*1hjVPA7DBce{7 zp+nASM*=?H#XceU=|e^2ZrD~dX&7)%Cgb75LX=}XP5$Oz_#Z$d{85H)Em#mB&Z!Qc zD&ohB6X4@Uta~tMA%>C(DXH-BViHi4Uv|JB`w;e@Z{^<};jr_-rA~SShjEk)LaGIt QCy&p6qyF~DxRL*V0f)vO3;+NC literal 0 HcmV?d00001 diff --git a/src/test/resources/fill/annotation.xlsx b/src/test/resources/fill/annotation.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..5395232b481e77439aabf34c9a7904807862a721 GIT binary patch literal 10692 zcmeHNWmHscyBD?vQSnLApDnLuqNGOOS355TsK&m6jNqGx~n#=*#Ol z|Ihlqz1HlRS+nnJ?b*+D-T5fX!92nSzyaU^0022)g|5K>1O)&P!vO$T0C;FUaYqLi za|ahAbq^r-cDhyBHZUPhK_dKf7do7g_1$XM&0?cRwNZZ1_|*Fn zktQ3HVi?#ffY=Kd^l0XBZTy_Q7_V4A-B$uAw;Vxr_pgIvH}G$;Vs?es!d>nHinhP% zC77Yw0s7v<34qz;bHg$SF+|$>L}Z*@{SW7_d3Q(@0#BqPFjp>^_bBqpM+6Z>!x7uW z@^-)b@Tn4HesQ%r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%h16q}0&Yx)kzmz0%kuYCiHL;V3 z4ip76!A+DqTI-9I>+04S(-k5wS{km%n~|c3J=P4Lrm}=)Gqxm5Ydc3#9Y+&xyS=*H z1kW7G)(CyN0@@MJ9K6p0!!gH18+3GZcCoF_$3MPNW>Uz-^WQdI$uj96cGBbmDD-+M}KQw+gSo>v+fc(cX z+e3hdjm}>HO_+aG8voPwd}#Wx`SZ(k73Y6${2#5LhbRy0{a+}Ykn;au1M%Ncepdev zQ682^zfhzgBga1#Ob-zr)(gK7yovsJA3v*yhbVu~5r1I-03##-z#lTkhX8+16n+Ol sB>x@YUunZb^S^ug-_64*e>4A=-&dA{g;4cJhZ_Z;0Aafc&5v*Y1=8Ts>;M1& literal 0 HcmV?d00001 diff --git a/update.md b/update.md index 7e791d8d..8a695624 100644 --- a/update.md +++ b/update.md @@ -1,5 +1,6 @@ # 3.0.4 * 调整读写默认大小,防止大批量写的时候可能会full gc +* `fill`的情况新增 `afterRowDispose`事件 # 3.0.3 * 修复`HeadStyle`无效的bug From 7dcba4cc88ea6c1998d556206d927d340cbaa30d Mon Sep 17 00:00:00 2001 From: Jiaju Zhuang Date: Tue, 9 Nov 2021 20:07:31 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../excel/write/executor/AbstractExcelWriteExecutor.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/alibaba/excel/write/executor/AbstractExcelWriteExecutor.java b/src/main/java/com/alibaba/excel/write/executor/AbstractExcelWriteExecutor.java index 44f55c80..7f8fe0ea 100644 --- a/src/main/java/com/alibaba/excel/write/executor/AbstractExcelWriteExecutor.java +++ b/src/main/java/com/alibaba/excel/write/executor/AbstractExcelWriteExecutor.java @@ -334,7 +334,8 @@ public abstract class AbstractExcelWriteExecutor implements ExcelWriteExecutor { } if (cellData == null || cellData.getType() == null) { throw new ExcelWriteDataConvertException(cellWriteHandlerContext, - "Convert data:" + cellWriteHandlerContext.getOriginalValue() + " return null, at row:" + "Convert data:" + cellWriteHandlerContext.getOriginalValue() + + " return is null or return type is null, at row:" + cellWriteHandlerContext.getRowIndex()); } return cellData;