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.)
Here is the code I used :
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. 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With