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)
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.