diff --git a/CHANGELOG.md b/CHANGELOG.md index 819af2b13..bcf9f9035 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ ### 🐣新特性 * 【core 】 SerializeUtil.deserialize增加白名单类,避免RCE vulnerability(issue#3021@Github) +* 【poi 】 ExcelWriter在关闭后不清空currentRow,以便复用(issue#3025@Github) ### 🐞Bug修复 * 【core 】 CollUtil.split优化切割列表参数判断,避免OOM(pr#3026@Github) diff --git a/hutool-poi/src/main/java/cn/hutool/poi/excel/ExcelWriter.java b/hutool-poi/src/main/java/cn/hutool/poi/excel/ExcelWriter.java index 6021dd159..39d6cb5cd 100755 --- a/hutool-poi/src/main/java/cn/hutool/poi/excel/ExcelWriter.java +++ b/hutool-poi/src/main/java/cn/hutool/poi/excel/ExcelWriter.java @@ -64,7 +64,7 @@ public class ExcelWriter extends ExcelBase { /** * 当前行 */ - private AtomicInteger currentRow = new AtomicInteger(0); + private final AtomicInteger currentRow; /** * 是否只保留别名对应的字段 */ @@ -182,6 +182,7 @@ public class ExcelWriter extends ExcelBase { public ExcelWriter(Sheet sheet) { super(sheet); this.styleSet = new StyleSet(workbook); + this.currentRow = new AtomicInteger(0); } // -------------------------------------------------------------------------- Constructor end @@ -1328,7 +1329,7 @@ public class ExcelWriter extends ExcelBase { super.close(); // 清空对象 - this.currentRow = null; + this.currentRow.set(0); this.styleSet = null; }