【问题标题】:Creating cell comments in apache poi (for .xlsx files) with show comments disabled在禁用显示注释的情况下在 apache poi(用于 .xlsx 文件)中创建单元格注释
【发布时间】: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


【解决方案1】:

帕罗什。我已经执行了您给出的相同代码。默认情况下,我只在悬停时获得 cmets。似乎不是代码问题,而是 Excel 设置问题。我已经在 excel 2010 中检查过。如果您有不同的版本,请检查类似的设置。

请检查主页 --> 选项 --> 高级 --> 显示...

应该选择“仅指示器,悬停时的 cmets”单选按钮。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-01-04
    • 1970-01-01
    • 1970-01-01
    • 2014-07-20
    • 1970-01-01
    • 2015-02-12
    • 1970-01-01
    相关资源
    最近更新 更多