From 665ba76f98ad2c0e6cc024e2eb6c0994279ff578 Mon Sep 17 00:00:00 2001 From: Looly Date: Fri, 30 Sep 2022 18:40:03 +0800 Subject: [PATCH] fix bug --- .../cn/hutool/poi/excel/reader/MapSheetReader.java | 3 ++- .../java/cn/hutool/poi/excel/IssueI5U1JATest.java | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100755 hutool-poi/src/test/java/cn/hutool/poi/excel/IssueI5U1JATest.java diff --git a/hutool-poi/src/main/java/cn/hutool/poi/excel/reader/MapSheetReader.java b/hutool-poi/src/main/java/cn/hutool/poi/excel/reader/MapSheetReader.java index ec8a2fc00..0324ff94e 100644 --- a/hutool-poi/src/main/java/cn/hutool/poi/excel/reader/MapSheetReader.java +++ b/hutool-poi/src/main/java/cn/hutool/poi/excel/reader/MapSheetReader.java @@ -46,7 +46,8 @@ public class MapSheetReader extends AbstractSheetReader } else if (headerRowIndex > lastRowNum) { throw new IndexOutOfBoundsException(StrUtil.format("Header row index {} is greater than last row index {}.", headerRowIndex, lastRowNum)); } else if (startRowIndex > lastRowNum) { - throw new IndexOutOfBoundsException(StrUtil.format("startRowIndex row index {} is greater than last row index {}.", startRowIndex, lastRowNum)); + // issue#I5U1JA 只有标题行的Excel,起始行是1,标题行(最后的行号是0) + return ListUtil.empty(); } final int startRowIndex = Math.max(this.startRowIndex, firstRowNum);// 读取起始行(包含) final int endRowIndex = Math.min(this.endRowIndex, lastRowNum);// 读取结束行(包含) diff --git a/hutool-poi/src/test/java/cn/hutool/poi/excel/IssueI5U1JATest.java b/hutool-poi/src/test/java/cn/hutool/poi/excel/IssueI5U1JATest.java new file mode 100755 index 000000000..a8946997b --- /dev/null +++ b/hutool-poi/src/test/java/cn/hutool/poi/excel/IssueI5U1JATest.java @@ -0,0 +1,13 @@ +package cn.hutool.poi.excel; + +import org.junit.Ignore; +import org.junit.Test; + +public class IssueI5U1JATest { + @Test + @Ignore + public void readAllTest() { + final ExcelReader reader = ExcelUtil.getReader("d:/test/issueI5U1JA.xlsx"); + reader.readAll(); + } +}