poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject svn commit: r1069775 - in /poi/trunk: src/documentation/content/xdocs/status.xml src/java/org/apache/poi/ss/usermodel/DataFormatter.java src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java test-data/spreadsheet/50756.xls
Date Fri, 11 Feb 2011 12:31:41 GMT
Author: nick
Date: Fri Feb 11 12:31:40 2011
New Revision: 1069775

URL: http://svn.apache.org/viewvc?rev=1069775&view=rev
Log:
Fix bug #50756 - When formatting numbers based on their Cell Style, treat GENERAL the same
as the more typical General

Added:
    poi/trunk/test-data/spreadsheet/50756.xls   (with props)
Modified:
    poi/trunk/src/documentation/content/xdocs/status.xml
    poi/trunk/src/java/org/apache/poi/ss/usermodel/DataFormatter.java
    poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.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=1069775&r1=1069774&r2=1069775&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/status.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/status.xml Fri Feb 11 12:31:40 2011
@@ -34,6 +34,7 @@
 
     <changes>
         <release version="3.8-beta1" date="2010-??-??">
+           <action dev="poi-developers" type="fix">50756 - When formatting numbers
based on their Cell Style, treat GENERAL the same as the more typical General</action>
            <action dev="poi-developers" type="fix">fixed HSSFWorkbook.createCellStyle
to throw exception if the maximum number of cell styles was exceeded</action>
            <action dev="poi-developers" type="fix">50539 - Better fix for html-style
br tags (invalid XML) inside XSSF documents</action>
            <action dev="poi-developers" type="add">49928 - allow overridden built-in
formats in HSSFCellStyle</action>

Modified: poi/trunk/src/java/org/apache/poi/ss/usermodel/DataFormatter.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/usermodel/DataFormatter.java?rev=1069775&r1=1069774&r2=1069775&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/usermodel/DataFormatter.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/usermodel/DataFormatter.java Fri Feb 11 12:31:40
2011
@@ -196,7 +196,7 @@ public class DataFormatter {
         if (format != null) {
             return format;
         }
-        if ("General".equals(formatStr) || "@".equals(formatStr)) {
+        if ("General".equalsIgnoreCase(formatStr) || "@".equals(formatStr)) {
             if (DataFormatter.isWholeNumber(cellValue)) {
                 return generalWholeNumFormat;
             }

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java?rev=1069775&r1=1069774&r2=1069775&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java Fri Feb 11 12:31:40
2011
@@ -43,6 +43,7 @@ import org.apache.poi.ss.formula.ptg.Ptg
 import org.apache.poi.ss.usermodel.BaseTestBugzillaIssues;
 import org.apache.poi.ss.usermodel.Cell;
 import org.apache.poi.ss.usermodel.CellStyle;
+import org.apache.poi.ss.usermodel.DataFormatter;
 import org.apache.poi.ss.usermodel.Name;
 import org.apache.poi.ss.usermodel.Row;
 import org.apache.poi.ss.usermodel.Sheet;
@@ -1953,4 +1954,36 @@ if(1==2) {
        assertEquals("Cell A,1", sheet.getRow(1).getCell(0).getStringCellValue());
        assertEquals("Cell A,3", sheet.getRow(2).getCell(0).getStringCellValue());
     }
+    
+    /**
+     * If you send a file between Excel and OpenOffice enough, something
+     *  will turn the "General" format into "GENERAL"
+     */
+    public void test50756() throws Exception {
+       HSSFWorkbook wb = openSample("50756.xls");
+       HSSFSheet s = wb.getSheetAt(0);
+       HSSFRow r17 = s.getRow(16);
+       HSSFRow r18 = s.getRow(17);
+       HSSFDataFormatter df = new HSSFDataFormatter();
+       
+       assertEquals(10.0, r17.getCell(1).getNumericCellValue());
+       assertEquals(20.0, r17.getCell(2).getNumericCellValue());
+       assertEquals(20.0, r17.getCell(3).getNumericCellValue());
+       assertEquals("GENERAL", r17.getCell(1).getCellStyle().getDataFormatString());
+       assertEquals("GENERAL", r17.getCell(2).getCellStyle().getDataFormatString());
+       assertEquals("GENERAL", r17.getCell(3).getCellStyle().getDataFormatString());
+       assertEquals("10", df.formatCellValue(r17.getCell(1)));
+       assertEquals("20", df.formatCellValue(r17.getCell(2)));
+       assertEquals("20", df.formatCellValue(r17.getCell(3)));
+       
+       assertEquals(16.0, r18.getCell(1).getNumericCellValue());
+       assertEquals(35.0, r18.getCell(2).getNumericCellValue());
+       assertEquals(123.0, r18.getCell(3).getNumericCellValue());
+       assertEquals("GENERAL", r18.getCell(1).getCellStyle().getDataFormatString());
+       assertEquals("GENERAL", r18.getCell(2).getCellStyle().getDataFormatString());
+       assertEquals("GENERAL", r18.getCell(3).getCellStyle().getDataFormatString());
+       assertEquals("16", df.formatCellValue(r18.getCell(1)));
+       assertEquals("35", df.formatCellValue(r18.getCell(2)));
+       assertEquals("123", df.formatCellValue(r18.getCell(3)));
+    }
 }

Added: poi/trunk/test-data/spreadsheet/50756.xls
URL: http://svn.apache.org/viewvc/poi/trunk/test-data/spreadsheet/50756.xls?rev=1069775&view=auto
==============================================================================
Binary file - no diff available.

Propchange: poi/trunk/test-data/spreadsheet/50756.xls
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream



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


Mime
View raw message