[Bug 63166] New: after using createCellComment to create comment for A1 cell first, cannot create comment for other cell any more.

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[Bug 63166] New: after using createCellComment to create comment for A1 cell first, cannot create comment for other cell any more.

Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=63166

            Bug ID: 63166
           Summary: after using createCellComment to create comment for A1
                    cell first, cannot create comment for other cell any
                    more.
           Product: POI
           Version: unspecified
          Hardware: PC
                OS: Mac OS X 10.1
            Status: NEW
          Severity: major
          Priority: P2
         Component: XSSF
          Assignee: [hidden email]
          Reporter: [hidden email]
  Target Milestone: ---

After using createCellComment to create comment for A1 cell first, cannot
create comment for other cell any more.

I have checked the source code in XSSFDrawing.java, it will always use
A1(row1,col1) to check if there is any comment in the cell. I think this is the
root cause for the issue

CellAddress ref = new CellAddress(ca.getRow1(), ca.getCol1());

----
Drawing drawing = sheet.createDrawingPatriarch();
 ClientAnchor anchor = createHelper.createClientAnchor();
 Comment comment = drawing.createCellComment(anchor);
 comment.setString(createHelper.createRichTextString(commentText));
----

XSSFDrawing.java:

 public XSSFComment createCellComment(ClientAnchor anchor) {
        XSSFClientAnchor ca = (XSSFClientAnchor)anchor;
        XSSFSheet sheet = this.getSheet();
        CommentsTable comments = sheet.getCommentsTable(true);
        XSSFVMLDrawing vml = sheet.getVMLDrawing(true);
        com.microsoft.schemas.vml.CTShape vmlShape = vml.newCommentShape();
        if (ca.isSet()) {
            int dx1Pixels = ca.getDx1() / 9525;
            int dy1Pixels = ca.getDy1() / 9525;
            int dx2Pixels = ca.getDx2() / 9525;
            int dy2Pixels = ca.getDy2() / 9525;
            String position = ca.getCol1() + ", " + dx1Pixels + ", " +
ca.getRow1() + ", " + dy1Pixels + ", " + ca.getCol2() + ", " + dx2Pixels + ", "
+ ca.getRow2() + ", " + dy2Pixels;
            vmlShape.getClientDataArray(0).setAnchorArray(0, position);
        }

        CellAddress ref = new CellAddress(ca.getRow1(), ca.getCol1());
        if (comments.findCellComment(ref) != null) {
            throw new IllegalArgumentException("Multiple cell comments in one
cell are not allowed, cell: " + ref);
        } else {
            return new XSSFComment(comments, comments.newComment(ref),
vmlShape);
        }
    }




java.lang.IllegalArgumentException: Multiple cell comments in one cell are not
allowed, cell: A1

        at
org.apache.poi.xssf.usermodel.XSSFDrawing.createCellComment(XSSFDrawing.java:398)
        at
org.apache.poi.xssf.streaming.SXSSFDrawing.createCellComment(SXSSFDrawing.java:52)

--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

[Bug 63166] after using createCellComment to create comment for A1 cell first, cannot create comment for other cell any more.

Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=63166

Dominik Stadler <[hidden email]> changed:

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

--- Comment #1 from Dominik Stadler <[hidden email]> ---
Can you post a full sample of how you trigger the problem?

You will need to populate the anchor with the intended reference to the Cell,
then it would use refs other than A1 correctly, or?

See https://poi.apache.org/components/spreadsheet/quick-guide.html#CellComments
for the description of how to use the API.

--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]