We have a lot of excel reports generated by apache poi. Some of them contains comments in headers. Because of many reports we want to create generic solution for adding comments. As we noticed comments can be added to cells by code like this:
public static void addComment(final Workbook workbook, final Sheet sheet, final Cell cell, final Row row,
final String comment) {
final CreationHelper factory = workbook.getCreationHelper();
final Drawing drawing = sheet.createDrawingPatriarch();
final ClientAnchor anchor = factory.createClientAnchor();
anchor.setCol1(cell.getColumnIndex());
anchor.setCol2(cell.getColumnIndex() + 3);
anchor.setRow1(row.getRowNum());
anchor.setRow2(row.getRowNum() + 5);
final Comment cellComment = drawing.createCellComment(anchor);
final RichTextString richText = factory.createRichTextString(comment);
cellComment.setString(richText);
cell.setCellComment(cellComment);
}
We also noticed that comment box size can by set using columns/rows index - this is the main problem for us because if first column has 100px and the second one has 1000px then comment width will be 1000px. Here is our question - is there a possibility to set comment size with pixels instead of columns/rows indexes using apache poi? Or maybe there is some way to automatically calculate comments size with apache poi?