Looly 5 years ago
parent
commit
537dfc80b7

+ 1 - 0
CHANGELOG.md

@@ -21,6 +21,7 @@
 * 【core   】     修复ZipUtil没有调用finish问题(issue#944@Github)
 * 【extra  】     修复Ftp中ArrayList长度为负问题(pr#136@Github)
 * 【core   】     修复Dict中putAll大小写问题(issue#I1MU5B@Gitee)
+* 【core   】     修复POI中sax读取数字判断错误问题(issue#931@Github)
 
 -------------------------------------------------------------------------------------------------------------
 ## 5.3.8 (2020-06-16)

+ 5 - 1
hutool-poi/src/main/java/cn/hutool/poi/excel/sax/ExcelSaxUtil.java

@@ -73,7 +73,11 @@ public class ExcelSaxUtil {
 				}
 				break;
 			case NUMBER:
-				result = getNumberValue(value, numFmtString);
+				try{
+					result = getNumberValue(value, numFmtString);
+				}catch (NumberFormatException e){
+					result = value;
+				}
 				break;
 			case DATE:
 				try {

+ 0 - 1
hutool-poi/src/test/java/cn/hutool/poi/excel/test/ExcelReadTest.java

@@ -213,5 +213,4 @@ public class ExcelReadTest {
 		final ExcelReader reader = ExcelUtil.getReader("merge_test.xlsx");
 		reader.read((cell, value)-> Console.log("{}, {} {}", cell.getRowIndex(), cell.getColumnIndex(), value));
 	}
-
 }

+ 2 - 4
hutool-poi/src/test/java/cn/hutool/poi/excel/test/ExcelSaxReadTest.java

@@ -115,10 +115,8 @@ public class ExcelSaxReadTest {
 	public void readBlankTest(){
 		File file = new File("D:/test/b.xlsx");
 
-		ExcelUtil.readBySax(file, 0, (sheetIndex, rowIndex, rowList) -> {
-			rowList.forEach(System.out::println);
-		});
+		ExcelUtil.readBySax(file, 0, (sheetIndex, rowIndex, rowList) -> rowList.forEach(Console::log));
 
-		ExcelUtil.getReader(file).read().forEach(System.out::println);
+		ExcelUtil.getReader(file).read().forEach(Console::log);
 	}
 }