From 2eafa12b31c9c65a12142ebc9f1fd9b817d9008b Mon Sep 17 00:00:00 2001 From: Looly Date: Fri, 26 May 2023 22:15:09 +0800 Subject: [PATCH] fix test --- .../org/dromara/hutool/poi/excel/sax/ExcelSaxUtil.java | 7 +++++-- .../org/dromara/hutool/poi/excel/ExcelSaxReadTest.java | 8 ++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/hutool-poi/src/main/java/org/dromara/hutool/poi/excel/sax/ExcelSaxUtil.java b/hutool-poi/src/main/java/org/dromara/hutool/poi/excel/sax/ExcelSaxUtil.java index 80be07baf..882f83240 100644 --- a/hutool-poi/src/main/java/org/dromara/hutool/poi/excel/sax/ExcelSaxUtil.java +++ b/hutool-poi/src/main/java/org/dromara/hutool/poi/excel/sax/ExcelSaxUtil.java @@ -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; diff --git a/hutool-poi/src/test/java/org/dromara/hutool/poi/excel/ExcelSaxReadTest.java b/hutool-poi/src/test/java/org/dromara/hutool/poi/excel/ExcelSaxReadTest.java index aac0b483f..44a2ec915 100644 --- a/hutool-poi/src/test/java/org/dromara/hutool/poi/excel/ExcelSaxReadTest.java +++ b/hutool-poi/src/test/java/org/dromara/hutool/poi/excel/ExcelSaxReadTest.java @@ -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 = 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