Bug 61728 - Cell Comments created with Apache POI have transparent background
Summary: Cell Comments created with Apache POI have transparent background
Status: NEW
Alias: None
Product: POI
Classification: Unclassified
Component: XSSF (show other bugs)
Version: 3.17-FINAL
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-11-06 13:18 UTC by Evgenii Balakhonov
Modified: 2017-11-06 18:01 UTC (History)
1 user (show)



Attachments
I use this file to add cells with comments (19.68 KB, application/vnd.ms-excel.sheet.macroEnabled.12)
2017-11-06 13:18 UTC, Evgenii Balakhonov
Details
Example of generated file with transparent comments (33.78 KB, application/vnd.ms-excel.sheet.macroEnabled.12)
2017-11-06 16:36 UTC, Evgenii Balakhonov
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Evgenii Balakhonov 2017-11-06 13:18:24 UTC
Created attachment 35497 [details]
I use this file to add cells with comments

I am using Apache POI 3.17 to create cell comments.

I have a need to add cell comments to XSSF sheets.

I have tried the code, suggested in POI FAQ. But my cell comments have  transparent background.

The code is reproduced below.

protected void setCellComment(Cell cell, String message) {
    Drawing drawing = cell.getSheet().createDrawingPatriarch();
    CreationHelper factory = cell.getSheet().getWorkbook()
            .getCreationHelper();
    // When the comment box is visible, have it show in a 1x3 space
    ClientAnchor anchor = factory.createClientAnchor();
    anchor.setCol1(cell.getColumnIndex());
    anchor.setCol2(cell.getColumnIndex() + 1);
    anchor.setRow1(cell.getRowIndex());
    anchor.setRow2(cell.getRowIndex() + 1);
    anchor.setDx1(100);
    anchor.setDx2(100);
    anchor.setDy1(100);
    anchor.setDy2(100);

    // Create the comment and set the text+author
    Comment comment = drawing.createCellComment(anchor);
    RichTextString str = factory.createRichTextString(message);
    comment.setString(str);
    comment.setAuthor("Apache POI");
    // Assign the comment to the cell
    cell.setCellComment(comment);
}
How can I change the background to a yellow background?

NOTE: If one edits the apache-poi created comment in Excel, then it will appear with a yellow background temporarily. However if one tries to format this comment to change the background from within Excel, then one can't. (The Color and Lines menu does not appear)
Comment 1 Javen O'Neal 2017-11-06 16:33:17 UTC
What version of Excel are you using?
Comment 2 Evgenii Balakhonov 2017-11-06 16:36:51 UTC
Created attachment 35498 [details]
Example of generated file with transparent comments
Comment 3 Evgenii Balakhonov 2017-11-06 16:56:03 UTC
(In reply to Javen O'Neal from comment #1)
> What version of Excel are you using?

Excel 2013. I attached generated file with example of transparent comments.
Comment 4 PJ Fanning 2017-11-06 18:01:34 UTC
I added the first comment using Excel and the other one was already in comment-example.xlsm. The first comment appears as black text on a yellow background while the other one appears as black text on a transparent background.

   <comment ref="B178" authorId="1">
        <text>
            <r>
                <rPr>
                    <b/>
                    <sz val="10"/>
                    <color indexed="81"/>
                    <rFont val="Calibri"/>
                </rPr>
                <t>xxx123xxx</t>
            </r>
            <r>
                <rPr>
                    <sz val="10"/>
                    <color indexed="81"/>
                    <rFont val="Calibri"/>
                </rPr>
                <t xml:space="preserve">
                </t>
            </r>
        </text>
    </comment>
    <comment ref="B191" authorId="0">
        <text>
            <r>
                <rPr>
                    <sz val="11"/>
                    <color theme="1"/>
                    <rFont val="Calibri"/>
                    <family val="2"/>
                    <charset val="204"/>
                    <scheme val="minor"/>
                </rPr>
                <t>Страна происхождения, где товар был изготовлен или обработан. Пример заполнения: Сделано в Германии. Данная информация отображается на упаковке товара.</t>
            </r>
        </text>
    </comment>