Hi All

Just a heads up that we had a regression in HSSF caused by r1061288, http://svn.apache.org/viewvc?view=revision&revision=1061288

As a consequence, new HSSF workbooks created from scratch could not be opened in Excel. I tested in Office 2007 and it complains that some of cell styles are invalid.

The regression was caused by the following change in InternalWorkbook:

+
         switch (id) {
- case 0: return new FormatRecord(5, "\"$\"#,##0_);\\(\"$\"#,##0\\)"); - case 1: return new FormatRecord(6, "\"$\"#,##0_);[Red]\\(\"$\"#,##0\\)"); - case 2: return new FormatRecord(7, "\"$\"#,##0.00_);\\(\"$\"#,##0.00\\)"); - case 3: return new FormatRecord(8, "\"$\"#,##0.00_);[Red]\\(\"$\"#,##0.00\\)"); - case 4: return new FormatRecord(0x2a, "_(\"$\"* #,##0_);_(\"$\"* \\(#,##0\\);_(\"$\"* \"-\"_);_(@_)"); - case 5: return new FormatRecord(0x29, "_(* #,##0_);_(* \\(#,##0\\);_(* \"-\"_);_(@_)"); - case 6: return new FormatRecord(0x2c, "_(\"$\"* #,##0.00_);_(\"$\"* \\(#,##0.00\\);_(\"$\"* \"-\"??_);_(@_)"); - case 7: return new FormatRecord(0x2b, "_(* #,##0.00_);_(* \\(#,##0.00\\);_(* \"-\"??_);_(@_)"); + case 0: return new FormatRecord(5, BuiltinFormats.getBuiltinFormat(5)); + case 1: return new FormatRecord(6, BuiltinFormats.getBuiltinFormat(6)); + case 2: return new FormatRecord(7, BuiltinFormats.getBuiltinFormat(7)); + case 3: return new FormatRecord(8, BuiltinFormats.getBuiltinFormat(8)); + case 4: return new FormatRecord(0x2a, BuiltinFormats.getBuiltinFormat(0x2a)); + case 5: return new FormatRecord(0x29, BuiltinFormats.getBuiltinFormat(0x29)); + case 6: return new FormatRecord(0x2c, BuiltinFormats.getBuiltinFormat(0x2c)); + case 7: return new FormatRecord(0x2b, BuiltinFormats.getBuiltinFormat(0x2b));
         }
         throw new  IllegalArgumentException("Unexpected id " + id);

The difference between the old and new code is that the old code escapes dollars and brackets and BuiltinFormats.getBuiltinFormat returns the raw format string. It appears that escaping special sumbols like $, ( and ) is important.

Since BuiltinFormats is a common class shared by HSSF and XSSF, I think it is best to escape format definitions hardcoded in it.
I committed the fix in r1069396.

Yegor

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to