【发布时间】:2013-04-19 07:54:56
【问题描述】:
我正在尝试使用 apache poi 创建单元格 cmets。我能够创建 cmets,但默认情况下它们始终显示在 excel 中。我必须手动右键单击单元格并取消勾选显示 cmets 以使其不可见(现在它们仅在我将鼠标悬停在单元格上时才会出现)。是否可以默认使单元格 cmets 不可见(以便在用户将鼠标悬停在单元格上之前它们不会出现在 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);
【问题讨论】:
-
您使用的是什么版本的 Apache POI?如果它不是最新的,您是否尝试过升级?
-
嗨 Gagravarr,我使用的是最新版本的 Apache POI 3.9。
标签: apache-poi xlsx xssf