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: [email protected]
Reporter: [email protected]
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: [email protected]
For additional commands, e-mail: [email protected]