Creating cell comments in apache poi (for .xlsx files) with view comments disabled

I am trying to create cell comments using apache poi. I can create comments, but by default they are always displayed in excel. I need to manually right-click on the cell and uncheck the comments to make them invisible (now they appear only when you hover over the cell). Is it possible to make comments on cells invisible by default (so that they do not appear in excel until the user hovers 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); 
+6
source share
1 answer

Paroksh. I executed the same code that you provided. By default, I only get comments when it hangs. It seems that the problem is not with the code, but with the Excel settings. I tested it in excel 2010. If you have a different version, check similar settings.

Please check Home → Option → Advanced → Show ...

there is "Only indicators and a switch with comments."

+2
source

All Articles