When HSSFDataFormat.getFormat need to add an entry in the "formats" table and that "!movedBuiltins", it will first move the content of the "builtinFormats" table to "formats". It does this with a (line 272): formats.add( ind, i.next() ); This will move the entries that are already there in "formats". Instead, I changed that to: formats.set( ind, i.next() ); This solves the problem I was experimenting. Just let me know if you need any additional information.
Created attachment 5050 [details] Patch against CVS
Testcase fails. Testsuite: org.apache.poi.hssf.usermodel.TestWorkbook Testcase: testWriteDataFormat took 0.01 sec Caused an ERROR Array index out of range: 45 java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 45 at java.util.Vector.set(Vector.java:713) at org.apache.poi.hssf.usermodel.HSSFDataFormat.getFormat(HSSFDataFormat.java:272) at org.apache.poi.hssf.usermodel.TestWorkbook.testWriteDataFormat(TestWorkbook.java:285)