[bug-69529] try to workaround cells with numeric type whose format cannot be applied

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1922985 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
PJ Fanning 2025-01-08 11:14:13 +00:00
parent 8d73b7ac2b
commit 116c32137d

View File

@ -426,10 +426,18 @@ public class XSSFSheetXMLHandler extends DefaultHandler {
case NUMBER:
String n = value.toString();
if (this.formatString != null && n.length() > 0)
thisStr = formatter.formatRawCellContents(Double.parseDouble(n), this.formatIndex, this.formatString);
else
if (this.formatString != null && n.length() > 0) {
try {
thisStr = formatter.formatRawCellContents(
Double.parseDouble(n), this.formatIndex, this.formatString);
} catch (NumberFormatException e) {
LOG.atInfo().log("Error formatting cell '{}' - will use its raw value instead",
cellRef);
thisStr = n;
}
} else {
thisStr = n;
}
break;
default: