From bad0c4c982605f15dd65e22f90d248278e4331f6 Mon Sep 17 00:00:00 2001 From: Looly Date: Wed, 26 Nov 2025 23:22:24 +0800 Subject: [PATCH] fix code --- .../v7/poi/excel/sax/Excel03SaxReader.java | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/hutool-poi/src/main/java/cn/hutool/v7/poi/excel/sax/Excel03SaxReader.java b/hutool-poi/src/main/java/cn/hutool/v7/poi/excel/sax/Excel03SaxReader.java index dfd55dc87..b618eba0f 100644 --- a/hutool-poi/src/main/java/cn/hutool/v7/poi/excel/sax/Excel03SaxReader.java +++ b/hutool-poi/src/main/java/cn/hutool/v7/poi/excel/sax/Excel03SaxReader.java @@ -80,7 +80,7 @@ public class Excel03SaxReader implements HSSFListener, ExcelSaxReader this.rid) { - return this.boundSheetRecords.get(this.rid > -1 ? this.rid : this.curRid).getSheetname(); + if (this.boundSheetRecords.size() > this.sheetIndex) { + return this.boundSheetRecords.get(this.sheetIndex > -1 ? this.sheetIndex : this.curRid).getSheetname(); } return null; @@ -190,7 +190,7 @@ public class Excel03SaxReader implements HSSFListener, ExcelSaxReader -1 && this.curRid > this.rid) { + if (this.sheetIndex > -1 && this.curRid > this.sheetIndex) { // 指定Sheet之后的数据不再处理 return; } @@ -200,7 +200,7 @@ public class Excel03SaxReader implements HSSFListener, ExcelSaxReader - *
  • 传入'rId'开头,直接去除rId前缀
  • - *
  • 传入纯数字,表示sheetIndex,直接转换为rid
  • + *
  • Excel03中没有rid概念,如果传入'rId'开头,直接去除rId前缀,按照sheetIndex对待
  • + *
  • 传入纯数字,表示sheetIndex
  • * * * @param idOrRidOrSheetName Excel中的sheet id或者rid编号或sheet名称,从0开始,rid必须加rId前缀,例如rId0,如果为-1处理所有编号的sheet * @return sheet索引,从0开始 * @since 5.5.5 */ - private int getRid(final String idOrRidOrSheetName) { + private int getSheetIndex(final String idOrRidOrSheetName) { Assert.notBlank(idOrRidOrSheetName, "id or rid or sheetName must be not blank!"); // rid直接处理