修复cloneSheet参数错误导致非XSSFWorkbook错误命名问题

This commit is contained in:
Looly
2023-12-23 16:14:14 +08:00
parent e5888f6bc6
commit aa85eff8f5
2 changed files with 4 additions and 2 deletions

View File

@@ -189,7 +189,8 @@ public class ExcelBase<T extends ExcelBase<T>> implements Closeable {
sheet = workbook.cloneSheet(sheetIndex, newSheetName);
} else {
sheet = this.workbook.cloneSheet(sheetIndex);
this.workbook.setSheetName(sheetIndex, newSheetName);
// issue#I8QIBBclone后的sheet的index应该重新获取
this.workbook.setSheetName(workbook.getSheetIndex(sheet), newSheetName);
}
if (setAsCurrentSheet) {
this.sheet = sheet;