Bug 48989 - If we have a comment but the row is not created we will not be able to get it.
Summary: If we have a comment but the row is not created we will not be able to get it.
Status: RESOLVED INVALID
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 3.6-FINAL
Hardware: PC Windows XP
: P2 trivial (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-03-25 16:09 UTC by Yury Gribkov
Modified: 2012-08-20 19:20 UTC (History)
1 user (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Yury Gribkov 2010-03-25 16:09:16 UTC
Regarding HSSFComment.getCellComment() we must have the row created; I bet it is unnecessary.
Comment 1 Evgeniy Berlog 2012-08-20 19:20:17 UTC
Hi, You can get cell comments using such chunk of code:

            HSSFWorkbook wb = new HSSFWorkbook();
            HSSFSheet sheet = wb.createSheet();
            Drawing drawing = sheet.createDrawingPatriarch();

            HSSFClientAnchor clientAnchor = new HSSFClientAnchor(0, 0, 0, 0, (short) 0, 0, (short)3, 3);
            Comment comment = drawing.createCellComment(clientAnchor);
            RichTextString str = new HSSFRichTextString("Hello, World!");
            comment.setString(str);
            comment.setRow(3);
            comment.setColumn(4);

            FileOutputStream out = new FileOutputStream("workbook.xls");
            wb.write(out);
            out.close();

            wb = new HSSFWorkbook(new FileInputStream("workbook.xls"));
            sheet = wb.getSheetAt(0);

            comment = sheet.getCellComment(3, 4);
            System.out.println(comment.getString().getString());

Regards, Evgeniy