Skip to content

Commit

Permalink
[bug-69529] try to workaround cells with numeric type whose format ca…
Browse files Browse the repository at this point in the history
…nnot be applied

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1922985 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
pjfanning committed Jan 8, 2025
1 parent 8d73b7a commit 116c321
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -426,10 +426,18 @@ private void outputCell() {

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:
Expand Down

0 comments on commit 116c321

Please sign in to comment.