相关疑难解决方法(0)

在apache poi(对于.xlsx文件)中创建单元格注释,并禁用显示注释

我正在尝试使用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)

xlsx apache-poi xssf

7
推荐指数
1
解决办法
5313
查看次数

标签 统计

apache-poi ×1

xlsx ×1

xssf ×1