多个评论apache poi

我正在尝试将多个注释分配给多个单元格。 当打开文件excel抱怨说:“Excel中发现不可读的内容…是否要恢复此工作簿的内容?

当我只有一个评论它的作品,2个或更多的评论失败。 看到我的代码如下:

String oper = "OPERATION TO DO AFTER UPLOAD"; Cell c = row.createCell(0); c.setCellType(Cell.CELL_TYPE_STRING); c.setCellValue(oper); c.setCellStyle(headerStyle); CreationHelper factory = wb.getCreationHelper(); Drawing drawing = sh.createDrawingPatriarch(); //comment for operation ClientAnchor anchor = factory.createClientAnchor(); anchor.setCol1(c.getColumnIndex()); anchor.setCol2(c.getColumnIndex()+1); anchor.setRow1(row.getRowNum()); anchor.setRow2(row.getRowNum()+3); Comment comment = drawing.createCellComment(anchor); RichTextString str = factory.createRichTextString("Please note that UPDATE will translate to INSERT (if ENTITY_ID column is empty) or UPDATE (if ENTITY_ID column is a number)"); comment.setString(str); comment.setAuthor("me"); // Assign the comment to the cell c.setCellComment(comment); String entity_id = "ENTITY ID"; c = row.createCell(1); c.setCellType(Cell.CELL_TYPE_STRING); c.setCellValue(entity_id); c.setCellStyle(headerStyle); // comment for EntityID ClientAnchor anchorEid = factory.createClientAnchor(); anchorEid.setCol1(c.getColumnIndex()); anchorEid.setCol2(c.getColumnIndex() + 1); anchorEid.setRow1(row.getRowNum()); anchorEid.setRow2(row.getRowNum() + 3); Comment commentEid = drawing.createCellComment(anchorEid); RichTextString strEid = factory .createRichTextString("Please note that UPDATE will translate to INSERT (if ENTITY_ID column is empty) or UPDATE (if ENTITY_ID column is a number)"); commentEid.setString(strEid); commentEid.setAuthor("me"); // Assign the comment to the cell c.setCellComment(commentEid); 

那里有什么问题? 我知道你必须创build绘图只有一次,但我没有交叉….

所以,当它使用SXSSF时,你不能使用评论(你不应该我猜)。 您只能添加一个在电子表格中有效的评论,这是有用的。

有关详细信息,请参阅位于此处的poi文档表: poi.apache.org/spreadsheet – >它在那里为SXSSF发表评论 – >否 (我certificate您可以有1条评论:))