mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
fix expty excel bug
This commit is contained in:
parent
7c866e10e0
commit
79e7fe93f6
@ -12,6 +12,7 @@
|
||||
### 🐞Bug修复
|
||||
* 【core 】 修复createScheduledExecutor单位不是毫秒的问题(issue#I3OYIW@Gitee)
|
||||
* 【core 】 修复Tailer无stop问题(issue#I3PQLQ@Gitee)
|
||||
* 【core 】 修复空白excel读取报错问题(issue#1552@Github)
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
@ -2,6 +2,7 @@ package cn.hutool.poi.excel.reader;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.IterUtil;
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
|
||||
@ -36,6 +37,10 @@ public class MapSheetReader extends AbstractSheetReader<List<Map<String, Object>
|
||||
// 边界判断
|
||||
final int firstRowNum = sheet.getFirstRowNum();
|
||||
final int lastRowNum = sheet.getLastRowNum();
|
||||
if(lastRowNum < 0){
|
||||
return ListUtil.empty();
|
||||
}
|
||||
|
||||
if (headerRowIndex < firstRowNum) {
|
||||
throw new IndexOutOfBoundsException(StrUtil.format("Header row index {} is lower than first row index {}.", headerRowIndex, firstRowNum));
|
||||
} else if (headerRowIndex > lastRowNum) {
|
||||
|
@ -217,4 +217,11 @@ public class ExcelReadTest {
|
||||
Assert.assertEquals("#", read.get(3).get(0));
|
||||
Assert.assertEquals("#", read.get(3).get(1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readEmptyTest(){
|
||||
final ExcelReader reader = ExcelUtil.getReader("d:/test/issue.xlsx");
|
||||
final List<Map<String, Object>> maps = reader.readAll();
|
||||
Console.log(maps);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user