diff --git a/src/main/java/com/alibaba/excel/util/NumberUtils.java b/src/main/java/com/alibaba/excel/util/NumberUtils.java index c467762c6..d52a3299d 100644 --- a/src/main/java/com/alibaba/excel/util/NumberUtils.java +++ b/src/main/java/com/alibaba/excel/util/NumberUtils.java @@ -95,14 +95,27 @@ public static Long parseLong(String string, ExcelContentProperty contentProperty } /** - * 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 000000000..92ef811d9 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 000000000..c6feb3251 Binary files /dev/null and b/src/test/resources/temp/issue2443/date2.xlsx differ