]> source.dussan.org Git - poi.git/commitdiff
bug 58775: fix a>b which should be a>=b; use shorts instead of ints to hold number...
authorJaven O'Neal <onealj@apache.org>
Mon, 28 Dec 2015 14:19:50 +0000 (14:19 +0000)
committerJaven O'Neal <onealj@apache.org>
Mon, 28 Dec 2015 14:19:50 +0000 (14:19 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1721923 13f79535-47bb-0310-9956-ffa450edef68

src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFDataFormat.java

index b14c6bdf30cf2046bf9121189d6c56677dc34d04..d2a9e5ba2cfb5e87b02ed5c4d49d571c4ed93032 100644 (file)
@@ -38,17 +38,20 @@ public final class TestXSSFDataFormat extends BaseTestDataFormat {
     public void test49928() {
         XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("49928.xlsx");
         doTest49928Core(wb);
+        
+        DataFormat dataFormat = wb.createDataFormat();
 
-        // an attempt to register an existing format returns its index
-        int poundFmtIdx = wb.getSheetAt(0).getRow(0).getCell(0).getCellStyle().getDataFormat();
-        assertEquals(poundFmtIdx, wb.getStylesSource().putNumberFormat(poundFmt));
+        // As of 2015-12-27, there is no way to override a built-in number format with POI XSSFWorkbook
+        // 49928.xlsx has been saved with a poundFmt that overrides the default value (dollar)
+        short poundFmtIdx = wb.getSheetAt(0).getRow(0).getCell(0).getCellStyle().getDataFormat();
+        assertEquals(poundFmtIdx, dataFormat.getFormat(poundFmt));
 
         // now create a custom format with Pound (\u00a3)
-        DataFormat dataFormat = wb.createDataFormat();
+        
         String customFmt = "\u00a3##.00[Yellow]";
         assertNotBuiltInFormat(customFmt);
         short customFmtIdx = dataFormat.getFormat(customFmt);
-        assertTrue(customFmtIdx > BuiltinFormats.FIRST_USER_DEFINED_FORMAT_INDEX );
+        assertTrue(customFmtIdx >= BuiltinFormats.FIRST_USER_DEFINED_FORMAT_INDEX);
         assertEquals(customFmt, dataFormat.getFormat(customFmtIdx));
     }