]> source.dussan.org Git - poi.git/commitdiff
Ensure consistent ordering when writing out formats following changes in r1677368
authorNick Burch <nick@apache.org>
Sun, 3 May 2015 07:59:18 +0000 (07:59 +0000)
committerNick Burch <nick@apache.org>
Sun, 3 May 2015 07:59:18 +0000 (07:59 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1677370 13f79535-47bb-0310-9956-ffa450edef68

src/ooxml/java/org/apache/poi/xssf/model/StylesTable.java

index 80b3a9ea93e27413dbc5b30c56b0441c2cd5b751..3937e3eeabdec449350b7a817d2854defd05a885 100644 (file)
@@ -378,10 +378,12 @@ public class StylesTable extends POIXMLDocumentPart {
         // Formats
         CTNumFmts formats = CTNumFmts.Factory.newInstance();
         formats.setCount(numberFormats.size());
-        for (Entry<Integer, String> fmt : numberFormats.entrySet()) {
-            CTNumFmt ctFmt = formats.addNewNumFmt();
-            ctFmt.setNumFmtId(fmt.getKey());
-            ctFmt.setFormatCode(fmt.getValue());
+        for (int fmtId=0; fmtId<usedNumberFormats.length; fmtId++) {
+            if (usedNumberFormats[fmtId]) {
+                CTNumFmt ctFmt = formats.addNewNumFmt();
+                ctFmt.setNumFmtId(fmtId);
+                ctFmt.setFormatCode(numberFormats.get(fmtId));
+            }
         }
         styleSheet.setNumFmts(formats);