Author: fanningpj
Date: Wed Jan  8 11:14:13 2025
New Revision: 1922985

URL: http://svn.apache.org/viewvc?rev=1922985&view=rev
Log:
[bug-69529] try to workaround cells with numeric type whose format cannot be 
applied

Modified:
    
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/eventusermodel/XSSFSheetXMLHandler.java

Modified: 
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/eventusermodel/XSSFSheetXMLHandler.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/eventusermodel/XSSFSheetXMLHandler.java?rev=1922985&r1=1922984&r2=1922985&view=diff
==============================================================================
--- 
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/eventusermodel/XSSFSheetXMLHandler.java
 (original)
+++ 
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/eventusermodel/XSSFSheetXMLHandler.java
 Wed Jan  8 11:14:13 2025
@@ -426,10 +426,18 @@ public class XSSFSheetXMLHandler extends
 
                 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:



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to