From b0515e7493ce2900ff48be5e706524ecb2d3d59c Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Wed, 8 Jan 2025 11:21:24 +0000 Subject: [PATCH] [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@1922986 13f79535-47bb-0310-9956-ffa450edef68 --- .../poi/xssf/eventusermodel/XSSFSheetXMLHandler.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/eventusermodel/XSSFSheetXMLHandler.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/eventusermodel/XSSFSheetXMLHandler.java index 047fee9ecd..effd61ccd2 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xssf/eventusermodel/XSSFSheetXMLHandler.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/eventusermodel/XSSFSheetXMLHandler.java @@ -396,6 +396,10 @@ public class XSSFSheetXMLHandler extends DefaultHandler { thisStr = formatter.formatRawCellContents(d, this.formatIndex, this.formatString); } catch (NumberFormatException e) { // Formula is a String result not a Numeric one + LOG.atInfo().log( + "Error formatting cell '{}' - will use its raw value instead (format '{}')", + cellRef, + this.formatString); thisStr = fv; } } else { @@ -431,8 +435,10 @@ public class XSSFSheetXMLHandler extends DefaultHandler { 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); + LOG.atInfo().log( + "Error formatting cell '{}' - will use its raw value instead (format '{}')", + cellRef, + this.formatString); thisStr = n; } } else {