From aa85eff8f5bec08b7d2a47579e7d908589c82a9b Mon Sep 17 00:00:00 2001 From: Looly Date: Sat, 23 Dec 2023 16:14:14 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DcloneSheet=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E5=AF=BC=E8=87=B4=E9=9D=9EXSSFWorkbook?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E5=91=BD=E5=90=8D=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 3 ++- hutool-poi/src/main/java/cn/hutool/poi/excel/ExcelBase.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e3e5b044..55470af25 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ # 🚀Changelog ------------------------------------------------------------------------------------------------------------- -# 5.8.24(2023-12-20) +# 5.8.24(2023-12-23) ### 🐣新特性 * 【cache 】 Cache增加get重载,可自定义超时时间(issue#I8G0DL@Gitee) @@ -30,6 +30,7 @@ * 【core 】 修复PostgreSQL使用upsert字段大小写问题问题(issue#I8PB4X@Gitee) * 【extra 】 修复TinyPinyinEngine可能的空指针问题(issue#3437@Github) * 【core 】 修复graalvm原生打包使用http工具被转为file协议问题(issue#I8PY3Y@Gitee) +* 【poi 】 修复cloneSheet参数错误导致非XSSFWorkbook错误命名问题(issue#I8QIBB@Gitee) ------------------------------------------------------------------------------------------------------------- # 5.8.23(2023-11-12) diff --git a/hutool-poi/src/main/java/cn/hutool/poi/excel/ExcelBase.java b/hutool-poi/src/main/java/cn/hutool/poi/excel/ExcelBase.java index 0e0481b7e..c86c134d6 100644 --- a/hutool-poi/src/main/java/cn/hutool/poi/excel/ExcelBase.java +++ b/hutool-poi/src/main/java/cn/hutool/poi/excel/ExcelBase.java @@ -189,7 +189,8 @@ public class ExcelBase> implements Closeable { sheet = workbook.cloneSheet(sheetIndex, newSheetName); } else { sheet = this.workbook.cloneSheet(sheetIndex); - this.workbook.setSheetName(sheetIndex, newSheetName); + // issue#I8QIBB,clone后的sheet的index应该重新获取 + this.workbook.setSheetName(workbook.getSheetIndex(sheet), newSheetName); } if (setAsCurrentSheet) { this.sheet = sheet;