From 0849d8c34ae8dda9a0a27fa96977c7c4e9c4d6d6 Mon Sep 17 00:00:00 2001 From: Javen O'Neal Date: Mon, 28 Dec 2015 14:19:50 +0000 Subject: [PATCH] bug 58775: fix a>b which should be a>=b; use shorts instead of ints to hold number format index git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1721923 13f79535-47bb-0310-9956-ffa450edef68 --- .../poi/xssf/usermodel/TestXSSFDataFormat.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFDataFormat.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFDataFormat.java index b14c6bdf3..d2a9e5ba2 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFDataFormat.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFDataFormat.java @@ -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)); }