]> source.dussan.org Git - poi.git/commitdiff
Bug 60906 -- fix style index
authorTim Allison <tallison@apache.org>
Thu, 23 Mar 2017 16:31:42 +0000 (16:31 +0000)
committerTim Allison <tallison@apache.org>
Thu, 23 Mar 2017 16:31:42 +0000 (16:31 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1788282 13f79535-47bb-0310-9956-ffa450edef68

src/ooxml/java/org/apache/poi/xssf/binary/XSSFBSheetHandler.java
src/ooxml/java/org/apache/poi/xssf/binary/XSSFBStylesTable.java

index 803306d407c00dc71ba413f3d0f1c45877fda163..5fd6d24e586e057513648bb19d99e06e5000f87c 100644 (file)
@@ -192,7 +192,8 @@ public class XSSFBSheetHandler extends XSSFBParser {
         beforeCellValue(data);
         double val = rkNumber(data, XSSFBCellHeader.length);
         String formatString = styles.getNumberFormatString(cellBuffer.getStyleIdx());
-        String formattedVal = dataFormatter.formatRawCellContents(val, cellBuffer.getStyleIdx(), formatString);
+        short styleIndex = styles.getNumberFormatIndex(cellBuffer.getStyleIdx());
+        String formattedVal = dataFormatter.formatRawCellContents(val, styleIndex, formatString);
         handleCellValue(formattedVal);
     }
 
index 10f3412a1e8a9ff72dc163d8864e26721206e233..583c9fcecfdec24ac46dd1cf53dac000b053cd30 100644 (file)
@@ -48,11 +48,16 @@ public class XSSFBStylesTable extends XSSFBParser {
     }
 
     String getNumberFormatString(int idx) {
-        if (numberFormats.containsKey(styleIds.get((short)idx))) {
-            return numberFormats.get(styleIds.get((short)idx));
+        short numberFormatIdx = getNumberFormatIndex(idx);
+        if (numberFormats.containsKey(numberFormatIdx)) {
+            return numberFormats.get(numberFormatIdx);
         }
 
-        return BuiltinFormats.getBuiltinFormat(styleIds.get((short)idx));
+        return BuiltinFormats.getBuiltinFormat(numberFormatIdx);
+    }
+
+    short getNumberFormatIndex(int idx) {
+        return styleIds.get(idx);
     }
 
     @Override