Created attachment 33812 [details] In the attachment a xlsx file with two cells and one of them created by POI. I insert a comment on a cell and set its visibile property to true value (by coding with POI). Then I open the file and see the dialog whith comment up. But if I just drag or click on the cell which contains the comment, the dialog disappears and therefore having a different behaviour respect to setting visible property to true by using menu.
Could you unzip the OOXML file and diff the Excel-created comment and POI-created comment? This should be the first step to determining what POI is doing incorrectly.
POI created OOXML: <?xml version="1.0" encoding="UTF-8"?> <comments xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><authors><author/></authors><commentList><comment ref="B2" authorId="0"><text><t>Commento visibile</t></text></comment></commentList></comments> EXCEL created OOXML: <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <comments xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><authors><author>Author</author></authors><commentList><comment ref="B2" authorId="0"><text><r><rPr><b/><sz val="9"/><color indexed="81"/><rFont val="Tahoma"/><charset val="1"/></rPr><t>Author:</t></r><r><rPr><sz val="9"/><color indexed="81"/><rFont val="Tahoma"/><charset val="1"/></rPr><t xml:space="preserve"> commento visibile</t></r></text></comment></commentList></comments> Actuaally they look really different. I cannot find any property to set other additional attribute.
(In reply to Javen O'Neal from comment #1) > Could you unzip the OOXML file and diff the Excel-created comment and > POI-created comment? This should be the first step to determining what POI > is doing incorrectly. POI created OOXML: <?xml version="1.0" encoding="UTF-8"?> <comments xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><authors><author/></authors><commentList><comment ref="B2" authorId="0"><text><t>Commento visibile</t></text></comment></commentList></comments> EXCEL created OOXML: <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <comments xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><authors><author>Author</author></authors><commentList><comment ref="B2" authorId="0"><text><r><rPr><b/><sz val="9"/><color indexed="81"/><rFont val="Tahoma"/><charset val="1"/></rPr><t>Author:</t></r><r><rPr><sz val="9"/><color indexed="81"/><rFont val="Tahoma"/><charset val="1"/></rPr><t xml:space="preserve"> commento visibile</t></r></text></comment></commentList></comments> Actuaally they look really different. I cannot find any property to set other additional attribute.
Hi, comparing two XML files, a POI-generated one and an Excel-generated one, it seems that the different behaviour is due to the \xl\drawingsvmlDrawing1.vml file. The Excel-generated one has an additional line apparently specifying the visibility, <x:Visible/>: <!-- ... --> <x:ClientData ObjectType="Note"> <x:MoveWithCells/> <x:SizeWithCells/> <x:Anchor>10, 0, 10, 0, 11, 0, 13, 0</x:Anchor> <x:AutoFill>False</x:AutoFill> <x:Row>0</x:Row> <x:Column>0</x:Column> <x:Visible/> </x:ClientData> <!-- ... --> If I unzip the POI-generated file, I add that line in the drawingsvmlDrawing1.vml file and then I open the file again, the comment visibility behaviour is preserved as expected. Thank you.
Can you post some sample-code how you populate the comment? The class XSSFVMLDrawing allows access to the low-level API CTShape and CTClientData which encapsulates the "visible" attribute.
Here's the code: /* ... */ XSSFWorkbook w = new XSSFWorkbook(); w.createSheet(); Comment commentToInsert = null; ClientAnchor anchorForComment = w.getCreationHelper().createClientAnchor(); anchorForComment.setAnchorType(3); anchorForComment.setCol1(1); anchorForComment.setCol2(4); anchorForComment.setRow1(1); anchorForComment.setRow2(4); anchorForComment.setDx1(100); anchorForComment.setDx2(400); anchorForComment.setDy1(100); anchorForComment.setDy2(400); Drawing drawingForComments = w.getSheetAt(0).createDrawingPatriarch(); commentToInsert = drawingForComments.createCellComment(anchorForComment); commentToInsert.setString(w.getCreationHelper().createRichTextString("Hi!")); w.getSheetAt(0).createRow(0).createCell(0).setCellComment(commentToInsert); //Setting cell comment visibility w.getSheetAt(0).getRow(0).getCell(0).getCellComment().setVisible(true); /* ... */
A proposed fix is available as PR at https://github.com/apache/poi/pull/236
https://github.com/apache/poi/pull/239 is now merged