Hello,

I generated comments for some cells in the Excel document. But, it seems
like the width of the comment depends on the width of the cell which is
very unintuitive. I know how wide (in pixels) the comment need to be to
work visually but sometimes it is attached to a wide cell and sometimes to
a very narrow cell. How can I set the comment width in pixels?

I found this on Stack Overflow but no answer unfortunately:

http://stackoverflow.com/questions/27960873/autosize-excel-comments-with-apache-poi

I use this code to generate comments:

    CreationHelper factory = wb.getCreationHelper();
    Drawing drawing = theSheet.createDrawingPatriarch();

    // When the comment box is visible, have it show in a 1x3 space
    ClientAnchor anchor = factory.createClientAnchor();
    anchor.setCol1(theCell.getColumnIndex());
    anchor.setCol2(theCell.getColumnIndex() + 1);
    anchor.setRow1(theCell.getRowIndex());
    anchor.setRow2(theCell.getRowIndex() + 3);

    // Create the comment and set the text+author
    Comment comment = drawing.createCellComment(anchor);
    RichTextString str = factory.createRichTextString("Comment string");
    comment.setString(str);
    comment.setAuthor("Author");


/Bengt

Reply via email to