我正在尝试使用apache poi创建单元格注释.我可以创建注释,但默认情况下它们始终显示在excel中.我必须手动右键单击单元格并取消勾选显示注释以使它们不可见(现在它们仅在我悬停在单元格上时出现).默认情况下是否可以使单元格注释不可见(以便在用户将鼠标悬停在单元格上之前它们不会出现在Excel中.)
这是我使用的代码:
Drawing drawing = cell.getSheet().createDrawingPatriarch();
CreationHelper factory = cell.getSheet().getWorkbook().getCreationHelper();
ClientAnchor anchor = factory.createClientAnchor();
anchor.setCol1(cell.getColumnIndex());
anchor.setCol2(cell.getColumnIndex() + 1);
anchor.setRow1(cell.getRowIndex());
anchor.setRow2(cell.getRowIndex() + 3);
Comment comment = drawing.createCellComment(anchor);
RichTextString str = factory.createRichTextString(message);
comment.setVisible(Boolean.FALSE);
comment.setString(str);
cell.setCellComment(comment);
Run Code Online (Sandbox Code Playgroud)