Summary: | Excel file can't be loaded if comments exceed a size of 4111 characters | ||
---|---|---|---|
Product: | POI | Reporter: | Jan Dostert <jan.dostert> |
Component: | HSSF | Assignee: | POI Developers List <dev> |
Status: | RESOLVED FIXED | ||
Severity: | normal | ||
Priority: | P2 | ||
Version: | 3.0-FINAL | ||
Target Milestone: | --- | ||
Hardware: | PC | ||
OS: | Windows XP |
Description
Jan Dostert
2007-08-10 08:28:22 UTC
Could you try the following: * Add a comment using POI of ~4000 characters * Take a copy of that file, and load it in Excel * Edit the comment in Excel, so that it's >4112 characters long * Compare the two files (hssf.dev and poifs.dev), and spot how excel has saved the large comment Once we know how Excel manages to generate larger comments, we can figure out the best way forward for POI to do the same I confirmed the problem. I could also reproduce it with HSSFTextbox - if I set text longer than 4111 characters the xls document gets corrupted. It's clear what's wrong. Excel records can't be longer than 8228 bytes, and text.length()*2 + header gets greater that the limit. BTW, POI fails to read such "bad" workbooks although there are no warnings while saving it. Here is the stack trace: Caused by: org.apache.poi.hssf.record.RecordFormatException: The content of an excel record cannot exceed 8224 bytes at org.apache.poi.hssf.record.RecordInputStream.nextRecord(RecordInputStream.java:108) at org.apache.poi.hssf.record.TextObjectRecord.fillFields(TextObjectRecord.java:47) Regards, Yegor Fixed. Record overflow wasn't properly handled in TextObjectRecord. Now it should work fine. Cell comments and Text Boxes can hold strings of any length. Regards, Yegor |