diff --git a/easyexcel-core/src/main/java/com/alibaba/excel/util/NumberUtils.java b/easyexcel-core/src/main/java/com/alibaba/excel/util/NumberUtils.java index c467762c..d52a3299 100644 --- a/easyexcel-core/src/main/java/com/alibaba/excel/util/NumberUtils.java +++ b/easyexcel-core/src/main/java/com/alibaba/excel/util/NumberUtils.java @@ -95,14 +95,27 @@ public class NumberUtils { } /** - * parse + * parse Integer from string * - * @param string - * @param contentProperty - * @return + * @param string An integer read in string format + * @param contentProperty Properties of the content read in + * @return An integer converted from a string */ public static Integer parseInteger(String string, ExcelContentProperty contentProperty) throws ParseException { if (!hasFormat(contentProperty)) { + // CS304 Issue link: https://github.com/alibaba/easyexcel/issues/2443 + int stringLength = string.length(); + if(stringLength>0){ + int pointer = stringLength; + for(int i=0;i(dataList -> { + for (Issue2443 issueData : dataList) { + log.info("读取到一条数据{}", JSON.toJSONString(issueData)); + } + })).sheet().doRead(); + } + //CS304 (manually written) Issue link: https://github.com/alibaba/easyexcel/issues/2443 + @Test + public void IssueTest2() { + String fileName = TestFileUtil.getPath() + "temp/issue2443" + File.separator + "date2.xlsx"; + EasyExcel.read(fileName, Issue2443.class, new PageReadListener(dataList -> { + for (Issue2443 issueData : dataList) { + log.info("读取到一条数据{}", JSON.toJSONString(issueData)); + } + })).sheet().doRead(); + } + + @Test + public void parseIntegerTest1() throws ParseException { + String string = "1.00"; + ExcelContentProperty contentProperty = null; + int Int = NumberUtils.parseInteger(string,contentProperty); + assertEquals(1, Int); + } + + @Test + public void parseIntegerTest2() throws ParseException { + String string = "2.00"; + ExcelContentProperty contentProperty = null; + int Int = NumberUtils.parseInteger(string,contentProperty); + assertEquals(2, Int); + } + +} diff --git a/src/test/resources/temp/issue2443/date1.xlsx b/src/test/resources/temp/issue2443/date1.xlsx new file mode 100644 index 00000000..92ef811d Binary files /dev/null and b/src/test/resources/temp/issue2443/date1.xlsx differ diff --git a/src/test/resources/temp/issue2443/date2.xlsx b/src/test/resources/temp/issue2443/date2.xlsx new file mode 100644 index 00000000..c6feb325 Binary files /dev/null and b/src/test/resources/temp/issue2443/date2.xlsx differ