https://issues.apache.org/bugzilla/show_bug.cgi?id=51676

             Bug #: 51676
           Summary: Using drawingPatriarch.createCellComment(anchor) leads
                    to File error: data may have been lost
           Product: POI
           Version: 3.7
          Platform: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: HSSF
        AssignedTo: [email protected]
        ReportedBy: [email protected]
    Classification: Unclassified


Created attachment 27403
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=27403
Corrupted file with comments

I have a case where uncommenting the "createCellComment()" suddenly leads to
the error message "File error: data may have been lost" when the file is opened
in Excel 2010.

The code for adding comments is:

        CreationHelper createHelper =
cell.getSheet().getWorkbook().getCreationHelper();
        Sheet sheet = cell.getSheet();
        Drawing drawingPatriarch = drawingPatriarches.get(sheet);
        if (drawingPatriarch == null) {
            drawingPatriarch = sheet.createDrawingPatriarch();
            drawingPatriarches.put(sheet, drawingPatriarch);
        }

        ClientAnchor anchor = createHelper.createClientAnchor();
        anchor.setCol1((short)4);
        anchor.setRow1(2);
        anchor.setCol2((short)10);
        anchor.setRow2(8);
        Comment comment = drawingPatriarch.createCellComment(anchor);
        comment.setString(createHelper.createRichTextString(text));
        cell.setCellComment(comment);


Funily it worked for a long time with the same code, but suddenly stopped
working a few days ago with updated data.

This is similar to Bug 48803, but I think it may be different than this issue
as it happens with different version and functionality involved.

Bug 50696 also talks about trouble with comments, but there it states that it
happens when an existing file is changed, however here I am working on a new
file each time.

I will attach the file that works and the one that does not work. I can not
easily extract a standalone testcase for this, let me know if you need one so I
spend the time only if necessary.

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

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to