并且禁用显示注释

并且禁用显示注释

本文介绍了在apache poi中创建单元注释(针对.xlsx文件),并且禁用显示注释的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用apache poi创建单元格注释.我可以创建评论,但默认情况下它们始终以excel形式显示.我必须手动右键单击该单元格,然后取消选中显示注释以使其不可见(现在它们仅在我将鼠标悬停在该单元格上时才显示).是否可以默认使单元格注释不可见(以便在用户将鼠标悬停在单元格上方之前,它们不会出现在excel中).

I am trying to create cells comments using apache poi. I am able to create the comments, but by default they are always displayed in excel. I have to manual right click on the cell and un-tick show comments to make them invisible(now they appear only when I hover on the cell). Is it possible to make cell comments invisible by default(so that they don't appear in the excel until user hover over the cell.)

这是我使用的代码:

    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);

推荐答案

Paroksh.我已经执行了您提供的相同代码.默认情况下,我仅获得关于悬停的评论.看来这不是代码问题,而是Excel设置问题.我已经在excel 2010中进行了检查.如果您使用的是其他版本,请检查类似的设置.

Paroksh. I have executed same code that you have given. By default, I am getting comments on hover only. It seems that it is not the code issue but the Excel settings issue. I have checked it in excel 2010. If you have different version then check the similar settings.

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

Please check Home --> Option --> Advanced --> Display...

应该选择仅指示器,并在悬停时添加注释"单选按钮.

there "Indicators only, and comments on hover" radio button should be selected.

这篇关于在apache poi中创建单元注释(针对.xlsx文件),并且禁用显示注释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 21:39