our Java EE applications writes large (>3000 rows, >300 columns) Excel files using Apache POI. We have implemented the customer’s requirement that many (>500) of the cells in the written file have a partial text formatting, i.e. the text in one cell is partially red and bold, and partially black.
Apache POI does not complain when writing the files, and they can be opened, BUT Excel 97 misdisplays them: parts of the cells have the wrong font size, and cells with multiple font colors cannot be changed (altering the font size on them does not work).
Also, Excel 2010 complains that the file is insecure (when downloaded from the server), and both Excel 97 and Excel 2010 crash on the exported files frequently.
The previous version of the application used JExcelApi and did not write multiformatted text cells. The files generated by the server using the previos (JExcelApi-powered) version of the application do display normally in Office2010, without the security warning.
Did anyone come across these issues and if so, how can I fix them?
Also, did anyone figure out why setting AutoFilters fails to show up in Office 2010 in the specified, yet shows up in Excel 97 correctly (so it sometimes crashes or works just until one AutoFilter is selected?).
Finally, I have tried to roundtrip an Excel export of the older version of the application, and found that Apache POI reduces the file size by >35%, while breaking the file’s contents – although no changes are applied (just reading the file into a HSSF Workbook and re-writing it into a ByteArrayOutputStream. Did anyone figure out how to prevent POI from altering the written file?
Thanks,
Michael
There’s a lot of questions here, but it sounds like POI is outputting records that 97 is misinterpreting. There are significant differences between a 97′ .xls and a 2003 .xls. The dialog behaving strangely is often a symptom of a malformed record. Excel 2010 has a binary file validator that it runs internally on any of the binary file format files (BIFF). It will pick up on any records that aren’t to the BIFF specifications.
I’m not sure what’s going on with the AutoFilters or the altering behavior.
If you’re having a lot of trouble with POI, you may wish to check out OfficeWriter which does a pretty good job with 2010 validation and styles in general.
DISCLAIMER: I’m one of the engineers who wrote the latest version.