From e34eb4314b289a456d895f3c77c39dd5605723a3 Mon Sep 17 00:00:00 2001 From: Looly Date: Wed, 29 Mar 2023 22:11:43 +0800 Subject: [PATCH] =?UTF-8?q?ExcelWriter=E5=9C=A8=E5=85=B3=E9=97=AD=E5=90=8E?= =?UTF-8?q?=E4=B8=8D=E6=B8=85=E7=A9=BAcurrentRow=EF=BC=8C=E4=BB=A5?= =?UTF-8?q?=E4=BE=BF=E5=A4=8D=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 1 + .../src/main/java/cn/hutool/poi/excel/ExcelWriter.java | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) 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; }