poi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 43088] New: - Excel file can't be loaded if comments exceed a size of 4111 characters
Date Fri, 10 Aug 2007 15:28:22 GMT
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


Mime
View raw message