This commit is contained in:
Looly 2023-05-26 22:15:09 +08:00
parent 458c38e421
commit 2eafa12b31
2 changed files with 9 additions and 6 deletions

View File

@ -85,7 +85,7 @@ public class ExcelSaxUtil {
cellDataType = CellDataType.NULL;
}
Object result;
Object result = null;
switch (cellDataType) {
case BOOL:
result = (value.charAt(0) != '0');
@ -117,7 +117,10 @@ public class ExcelSaxUtil {
default:
try {
result = getNumberValue(value, numFmtString);
} catch (final NumberFormatException e) {
} catch (final NumberFormatException ignore) {
}
if(null == result){
result = value;
}
break;

View File

@ -1,6 +1,7 @@
package org.dromara.hutool.poi.excel;
import org.dromara.hutool.core.collection.CollUtil;
import org.dromara.hutool.core.collection.ListUtil;
import org.dromara.hutool.core.convert.Convert;
import org.dromara.hutool.core.io.IoUtil;
import org.dromara.hutool.core.io.file.FileUtil;
@ -217,14 +218,13 @@ public class ExcelSaxReadTest {
}
@Test
//@Disabled
public void readBlankTest() {
final File file = FileUtil.file("aaa.xlsx");
ExcelUtil.readBySax(file, 0, (sheetIndex, rowIndex, rowList) -> Console.log(rowList));
final List<List<Object>> list = ListUtil.of();
ExcelUtil.readBySax(file, 0, (sheetIndex, rowIndex, rowList) -> list.add(rowList));
Console.log("-------------------------------------");
ExcelUtil.getReader(file).read().forEach(Console::log);
Assertions.assertEquals("[, 女, , 43.22]", list.get(3).toString());
}
@Test