Bug 47188 - setCellComment corrupts workbook (2007 XML format)
Summary: setCellComment corrupts workbook (2007 XML format)
Status: RESOLVED LATER
Alias: None
Product: POI
Classification: Unclassified
Component: XSSF (show other bugs)
Version: 3.5-dev
Hardware: PC Windows Server 2003
: P2 major (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-05-12 23:33 UTC by Vinu Kumar
Modified: 2011-02-25 17:04 UTC (History)
0 users



Attachments
Attachment for the bug (59.81 KB, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
2009-05-12 23:33 UTC, Vinu Kumar
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Vinu Kumar 2009-05-12 23:33:58 UTC
Created attachment 23648 [details]
Attachment for the bug

XSSFComment comment = sheet.createComment() and then calling
cell.setCellComment(comment);

corrupts the workbook.

Opening the workbook gives the following error:

Removed Records: Comments from /xl/comments1.xml part (Comments)
Comment 1 Yegor Kozlov 2009-11-30 06:45:11 UTC
the problem should be fixed in r884918.

Was the attached template created by POI? If so, please re-create it using the
latest build from trunk. Your template contains comments not having visual
properties that are stored in the vmlDrawing.vml part. r884918 fixed this and
some other bugs.

Yegor
Comment 2 Vinu Kumar 2009-12-01 23:57:41 UTC
Now setting comment on a xlsx file works!
Comment 3 rajeev 2009-12-21 03:32:09 UTC
Hi,
I have tried creating comments in the excel file, using below code

ClientAnchor anchor = ch.createClientAnchor();
                    Comment comment = drawing.createCellComment(anchor);
                    comment.setString(ch.createRichTextString(alias));
                    cell.setCellComment(comment);

after writing the xls and opening the file it gives error "File error data may have been lost" and opens the file

In the file, content is anchored to first cell as well as minimized which you need to expand to see the comment. 

Rajeev
Comment 4 rajeev 2009-12-21 03:39:47 UTC
Reopening the bug.
Comment 5 Yegor Kozlov 2009-12-21 06:29:20 UTC
Rajeev,

Please attach sample code to reproduce the problem. The code snippet you posted is not enough. If your code uses a template then attach it as well. 

Which version of POI are you using? Make sure it is POI-3.6 or 3.7-SNAPSHOT. 

Yegor
Comment 6 rajeev 2010-01-06 03:58:33 UTC
yes I am using 3.6 and without any template
below is the code snippet

	ClientAnchor anchor = ch.createClientAnchor();
                    	anchor.setCol1(6+i);
                    	anchor.setRow1(4+i);
                    	anchor.setCol2(12+i);
                    	anchor.setRow2(13+i);
                    	anchor.setDx1(i*4);
                    	anchor.setDy1(i*4);
                    	anchor.setDx2(i*4);
                    	anchor.setDy2(i*4);
                    	
                    	Comment comment = drawing.createCellComment(anchor);
                    	comment.setString(ch.createRichTextString(alias));
                    	comment.setColumn(i);
                    	comment.setRow(0);
                    	cell.setCellComment(comment);

Setting co-ordinates solved the anchoring problem but still i guess the same old error

Opening the workbook gives the following error:

Removed Records: Comments from /xl/comments1.xml part (Comments)

Not sure whether I am missing anything.
Comment 7 rajeev 2010-01-06 04:53:36 UTC
changing the status after providing asked info
Comment 8 Yegor Kozlov 2010-01-24 06:00:33 UTC
Rajeev,

I can't reproduce the problem with the current trunk. The following code snippet works fine and produces readable output: 

    public static void main(String[] args) throws Exception {
        Workbook wb = new XSSFWorkbook();
        Sheet sh = wb.createSheet();

        int i = 0;
        Cell cell = sh.createRow(0).createCell(i);
        CreationHelper ch = wb.getCreationHelper();
        Drawing drawing = sh.createDrawingPatriarch();

        ClientAnchor anchor = ch.createClientAnchor();
        anchor.setCol1(6+i);
        anchor.setRow1(4+i);
        anchor.setCol2(12+i);
        anchor.setRow2(13+i);
        anchor.setDx1(i*4);
        anchor.setDy1(i*4);
        anchor.setDx2(i*4);
        anchor.setDy2(i*4);

        Comment comment = drawing.createCellComment(anchor);
        comment.setString(ch.createRichTextString("Testing 47188"));
        comment.setColumn(i);
        comment.setRow(0);
        cell.setCellComment(comment);

        FileOutputStream out = new FileOutputStream("/temp/47188.xlsx");
        wb.write(out);
        out.close();
    }

Try the latest build from trunk. Nightly builds can be downloaded from http://encore.torchbox.com/poi-svn-build/. 

If the problem persists, please attach full sample code to reproduce, ideally a junit test case.

Yegor
Comment 9 Nick Burch 2011-02-25 17:04:02 UTC
I believe this is now fixed, please re-open if the problem remains with a recent svn nightly build / recent release, and include details of how to replicate the problem