You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ni...@apache.org on 2011/12/20 06:34:58 UTC

svn commit: r1221103 - in /poi/trunk/src: documentation/content/xdocs/status.xml ooxml/java/org/apache/poi/xssf/eventusermodel/XSSFSheetXMLHandler.java

Author: nick
Date: Tue Dec 20 05:34:58 2011
New Revision: 1221103

URL: http://svn.apache.org/viewvc?rev=1221103&view=rev
Log:
Fix bug #52369 - Event based XSSF parsing should handle formatting of formula values in XSSFSheetXMLHandler

Modified:
    poi/trunk/src/documentation/content/xdocs/status.xml
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/eventusermodel/XSSFSheetXMLHandler.java

Modified: poi/trunk/src/documentation/content/xdocs/status.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/status.xml?rev=1221103&r1=1221102&r2=1221103&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/status.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/status.xml Tue Dec 20 05:34:58 2011
@@ -34,6 +34,7 @@
 
     <changes>
         <release version="3.8-beta6" date="2012-??-??">
+           <action dev="poi-developers" type="fix">52369 - Event based XSSF parsing should handle formatting of formula values in XSSFSheetXMLHandler</action>
            <action dev="poi-developers" type="fix">52348 - Avoid exception when creating cell style in a workbook that has an empty xf table</action>
            <action dev="poi-developers" type="fix">52219 - fixed XSSFSimpleShape to set rich text attributes from XSSFRichtextString</action>
            <action dev="poi-developers" type="fix">52314 - enhanced SheetUtil.getColumnWidth</action>

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/eventusermodel/XSSFSheetXMLHandler.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/eventusermodel/XSSFSheetXMLHandler.java?rev=1221103&r1=1221102&r2=1221103&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/eventusermodel/XSSFSheetXMLHandler.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/eventusermodel/XSSFSheetXMLHandler.java Tue Dec 20 05:34:58 2011
@@ -242,7 +242,21 @@ public class XSSFSheetXMLHandler extends
                    if(formulasNotResults) {
                       thisStr = formula.toString();
                    } else {
-                      thisStr = value.toString();
+                      String fv = value.toString();
+                      
+                      if (this.formatString != null) {
+                         try {
+                            // Try to use the value as a formattable number
+                            double d = Double.parseDouble(fv);
+                            thisStr = formatter.formatRawCellContents(d, this.formatIndex, this.formatString);
+                         } catch(NumberFormatException e) {
+                            // Formula is a String result not a Numeric one
+                            thisStr = fv;
+                         }
+                      } else {
+                         // No formatter supplied, just do raw value in all cases
+                         thisStr = fv;
+                      }
                    }
                    break;
 



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org