fix null bug

This commit is contained in:
Looly 2021-10-16 00:27:13 +08:00
parent 3ed26fe761
commit 644d1c22c7
3 changed files with 17 additions and 6 deletions

View File

@ -3,7 +3,7 @@
------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------
# 5.7.15 (2021-10-15) # 5.7.15 (2021-10-16)
### 🐣新特性 ### 🐣新特性
* 【db 】 Db.quietSetAutoCommit增加判空issue#I4D75B@Gitee * 【db 】 Db.quietSetAutoCommit增加判空issue#I4D75B@Gitee
@ -16,6 +16,7 @@
* 【core 】 修复CollUtil.isEqualList两个null返回错误问题issue#1885@Github * 【core 】 修复CollUtil.isEqualList两个null返回错误问题issue#1885@Github
* 【poi 】 修复ExcelWriter多余调试信息导致的问题issue#1884@Github * 【poi 】 修复ExcelWriter多余调试信息导致的问题issue#1884@Github
* 【poi 】 修复TemporalAccessorUtil.toInstant使用DateTimeFormatter导致问题issue#1891@Github * 【poi 】 修复TemporalAccessorUtil.toInstant使用DateTimeFormatter导致问题issue#1891@Github
* 【poi 】 修复sheet.getRow(y)为null导致的问题issue#1893@Github
------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------

View File

@ -281,11 +281,13 @@ public class ExcelReader extends ExcelBase<ExcelReader> {
short columnSize; short columnSize;
for (int y = startRowIndex; y <= endRowIndex; y++) { for (int y = startRowIndex; y <= endRowIndex; y++) {
row = this.sheet.getRow(y); row = this.sheet.getRow(y);
columnSize = row.getLastCellNum(); if(null != row){
Cell cell; columnSize = row.getLastCellNum();
for (short x = 0; x < columnSize; x++) { Cell cell;
cell = row.getCell(x); for (short x = 0; x < columnSize; x++) {
cellHandler.handle(cell, CellUtil.getCellValue(cell)); cell = row.getCell(x);
cellHandler.handle(cell, CellUtil.getCellValue(cell));
}
} }
} }
} }

View File

@ -4,6 +4,7 @@ import cn.hutool.core.io.resource.ResourceUtil;
import cn.hutool.core.lang.Console; import cn.hutool.core.lang.Console;
import cn.hutool.core.map.MapUtil; import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.poi.excel.cell.CellHandler;
import lombok.Data; import lombok.Data;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Ignore; import org.junit.Ignore;
@ -225,4 +226,11 @@ public class ExcelReadTest {
final List<Map<String, Object>> maps = reader.readAll(); final List<Map<String, Object>> maps = reader.readAll();
Console.log(maps); Console.log(maps);
} }
@Test
@Ignore
public void readNullRowTest(){
final ExcelReader reader = ExcelUtil.getReader("d:/test/1.-.xls");
reader.read((CellHandler) Console::log);
}
} }