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