You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2007/08/10 17:28:22 UTC

DO NOT REPLY [Bug 43088] New: - Excel file can't be loaded if comments exceed a size of 4111 characters

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=43088>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=43088

           Summary: Excel file can't be loaded if comments exceed a size of
                    4111 characters
           Product: POI
           Version: 3.0
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: normal
          Priority: P2
         Component: HSSF
        AssignedTo: dev@poi.apache.org
        ReportedBy: jan.dostert@sap.com


Hi,

this bug seems to be similar to bug 42920 (Excel Comments).

When attaching comments to a cell with poi-3.0.1-FINAL-20070705.jar and the
comments exceed a size of 4111 characters, the file can't be loaded by Excel any
more (I tried Excel 2003 and Excel 2007).

There are no problems in saving the file. However, when opening the file with
Excel, I get the error message "Excel found unreadable content in foo.xls".

Attached a small test case which reproduces the problem. The created excel file
works fine if the comment size is up to 4111 characters. But with a comment size
of 4112 characters, the excel file can't be loaded any more.

import java.io.FileOutputStream;

import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFClientAnchor;
import org.apache.poi.hssf.usermodel.HSSFComment;
import org.apache.poi.hssf.usermodel.HSSFPatriarch;
import org.apache.poi.hssf.usermodel.HSSFRichTextString;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;

public class Comments {

    public static void main(String args[]) throws Exception {

        HSSFWorkbook workBook = new HSSFWorkbook();
        HSSFSheet sheet = workBook.createSheet();
        HSSFPatriarch patriarch = sheet.createDrawingPatriarch();
        
        HSSFRow row = sheet.createRow(0);
        HSSFCell cell = row.createCell((short)0);

        // works  with 4111
        // broken with 4112
        int size = 4112;
        
        StringBuffer toolTip = new StringBuffer(size);
        for (int i = 0; i < size; i++) {
            toolTip.append(".");
        }
        
        HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 0, 0, (short)0, 0,
(short)1, 1);
        HSSFComment comment = patriarch.createComment(anchor);
        comment.setString(new HSSFRichTextString(toolTip.toString()));
        cell.setCellComment(comment);
        
        workBook.write(new FileOutputStream("foo.xls"));
    }
}

Regards,
Jan

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


DO NOT REPLY [Bug 43088] - Excel file can't be loaded if comments exceed a size of 4111 characters

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=43088>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=43088


yegor@dinom.ru changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED




------- Additional Comments From yegor@dinom.ru  2007-08-26 08:08 -------
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


-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


DO NOT REPLY [Bug 43088] - Excel file can't be loaded if comments exceed a size of 4111 characters

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=43088>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=43088


yegor@dinom.ru changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEEDINFO                    |ASSIGNED




------- Additional Comments From yegor@dinom.ru  2007-08-24 11:18 -------
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


-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


DO NOT REPLY [Bug 43088] - Excel file can't be loaded if comments exceed a size of 4111 characters

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=43088>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=43088


nick@torchbox.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |NEEDINFO




------- Additional Comments From nick@torchbox.com  2007-08-15 04:57 -------
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

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org