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 d52a3299..4646c396 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 @@ -75,7 +75,7 @@ public class NumberUtils { */ public static Short parseShort(String string, ExcelContentProperty contentProperty) throws ParseException { if (!hasFormat(contentProperty)) { - return Short.valueOf(string); + return new BigDecimal(string).shortValue(); } return parse(string, contentProperty).shortValue(); } @@ -89,7 +89,7 @@ public class NumberUtils { */ public static Long parseLong(String string, ExcelContentProperty contentProperty) throws ParseException { if (!hasFormat(contentProperty)) { - return Long.valueOf(string); + return new BigDecimal(string).longValue(); } return parse(string, contentProperty).longValue(); } @@ -97,26 +97,13 @@ public class NumberUtils { /** * parse Integer from string * - * @param string An integer read in string format + * @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