Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Excel File Loading Issue: Invalid Character in BigDecimal Conversion #4081

Open
alex1972000 opened this issue Jan 20, 2025 · 0 comments
Open
Assignees
Labels
bug Something isn't working

Comments

@alex1972000
Copy link

When loading an Excel file, an error occurs with the message: "Character is neither a decimal digit number, decimal point, nor "e" notation exponential mark." This issue appears to be caused by inadequate exception handling in the CellTagHandler class, specifically in rows 85-95.

your code snippet: case NUMBER:
case EMPTY:
if (StringUtils.isEmpty(tempDataString)) {
tempCellData.setType(CellDataTypeEnum.EMPTY);
break;
}
tempCellData.setType(CellDataTypeEnum.NUMBER);
tempCellData.setOriginalNumberValue(new BigDecimal(tempDataString));
tempCellData.setNumberValue(
tempCellData.getOriginalNumberValue().round(EasyExcelConstants.EXCEL_MATH_CONTEXT));
break;

Expected Behavior
The application should handle cells with trailing spaces or non-numeric characters gracefully, either by trimming the value or providing a more informative error message.

Actual Behavior
The application throws an exception with the message: "Character is neither a decimal digit number, decimal point, nor "e" notation exponential mark."

Proposed Solution
Implement exception handling for BigDecimal creation in the CellTagHandler class. Consider the following approaches:
Trim whitespace from cell values before attempting to create a BigDecimal.
Implement a try-catch block to handle NumberFormatException and provide a more user-friendly error message.
Add validation to check for non-numeric characters before BigDecimal conversion.

@alex1972000 alex1972000 added the bug Something isn't working label Jan 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants