poi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject [Bug 56835] New: Unreadable content when adding multiple comments to
Date Sun, 10 Aug 2014 10:07:36 GMT

            Bug ID: 56835
           Summary: Unreadable content when adding multiple comments to
           Product: POI
           Version: 3.10-FINAL
          Hardware: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: XSSF
          Assignee: dev@poi.apache.org
          Reporter: iceardor@gmail.com

Tested on 3.10-FINAL and 3.11 nightly 2014-07-21 (nothing special about this
build, I just happened to have it on my system)

If I use POI to add two comments to the same cell in an XSSFWorkbook, after
writing the workbook to disk, when I open the file in Microsoft Excel, I
receive the following error dialog:

Microsoft Excel
"Excel found unreadable content in 'add_two_comments_to_one_cell_test.xlsx'. Do
you want to recover the contents of this workbook? If you trust the source of
this workbook, click Yes."
Yes | No

Repairs to 'add_two_comments_to_one_cell_test.xlsx'.
Excel was able to open the file by repairing or removing the unreadable
Removed Records: Comments from /xl/comments1.xml.part (Comments)

Upon opening the repaired file, only the first comment appears to be in the
workbook. The second comment was removed in the repair process.

Since Microsoft Excel can't handle multiple comments in the same cell (comments
with the same Col1 and Row1), should POI should raise an error or warning when
trying to add a second comment to a cell?

Java code to reproduce the issue (translated from Jython)

class TestWriteTwoCommentsToOneCell {
    public static void main(String[] args) throws Exception {
        Workbook wb = new XSSFWorkbook();
        Cell cell = wb.createSheet('Sheet1').createRow(0).createCell(0);

        addCommentToCell(cell, "First comment", "Apache POI");
        addCommentToCell(cell, "Second comment", "Apache POI");

        FileOutputStream out = new

    public void addComment(Cell cell, String commentText, String author) {
        Sheet sheet = cell.getSheet();
        Row row = cell.getRow();
        Drawing drawing = sheet.createDrawingPatriarch();

        // When the comment box is visible, have it show in a 1x3 space
        ClientAnchor anchor = factory.createClientAnchor();

        // Create the comment and set the text+author
        Comment comment = drawing.createCellComment(anchor);
        RichTextString str = factory.createRichTextString(commentText);

        // Assign the comment to the cell

You are receiving this mail because:
You are the assignee for the bug.

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

View raw message