Commit e7182f44 by zhouhaibao

fix(excel): 修复数字转换器中的异常处理问题

- IntegerStringConverter中NumberFormatException时返回null而不是抛出异常
- NumberStringConverter中NumberFormatException时返回null而不是抛出异常
- PercentStringConverter中移除百分比计算的除以100操作并改进异常处理
- 统一三个转换器类中的错误处理逻辑,避免程序崩溃
1 parent 44b3f0a3
......@@ -43,7 +43,7 @@ public class IntegerStringConverter implements Converter<Integer> {
BigDecimal decimal = new BigDecimal(stringValue);
return decimal.intValue();
} catch (NumberFormatException e) {
throw new NumberFormatException("Invalid number format: " + stringValue);
return null;
}
}
......
......@@ -42,7 +42,7 @@ public class NumberStringConverter implements Converter<BigDecimal> {
try {
return new BigDecimal(stringValue);
} catch (NumberFormatException e) {
throw new NumberFormatException("Invalid number format: " + stringValue);
return null;
}
}
......
......@@ -47,7 +47,7 @@ public class PercentStringConverter implements Converter<BigDecimal> {
}
try {
BigDecimal value = new BigDecimal(numStr);
return value.divide(new BigDecimal("100"), 4, RoundingMode.HALF_UP);
return value;
} catch (NumberFormatException e) {
return null;
}
......@@ -56,7 +56,7 @@ public class PercentStringConverter implements Converter<BigDecimal> {
try {
return new BigDecimal(stringValue);
} catch (NumberFormatException e) {
throw new NumberFormatException("Invalid number format: " + stringValue);
return null;
}
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!