Bug 51676 - Using drawingPatriarch.createCellComment(anchor) leads to File error: data may have been lost
Summary: Using drawingPatriarch.createCellComment(anchor) leads to File error: data ma...
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 3.7-FINAL
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Blocks: 53010
  Show dependency tree
Reported: 2011-08-18 11:19 UTC by Dominik Stadler
Modified: 2012-08-15 20:21 UTC (History)
0 users

Corrupted file with comments (288.00 KB, application/vnd.ms-excel)
2011-08-18 11:19 UTC, Dominik Stadler
Same content without comments works fine (47.00 KB, application/vnd.ms-excel)
2011-08-18 11:20 UTC, Dominik Stadler

Note You need to log in before you can comment on or make changes to this bug.
Description Dominik Stadler 2011-08-18 11:19:24 UTC
Created attachment 27403 [details]
Corrupted file with comments

I have a case where uncommenting the "createCellComment()" suddenly leads to the error message "File error: data may have been lost" when the file is opened in Excel 2010.

The code for adding comments is:

	    CreationHelper createHelper = cell.getSheet().getWorkbook().getCreationHelper();
	    Sheet sheet = cell.getSheet();
	    Drawing drawingPatriarch = drawingPatriarches.get(sheet);
	    if (drawingPatriarch == null) {
	        drawingPatriarch = sheet.createDrawingPatriarch();
	        drawingPatriarches.put(sheet, drawingPatriarch);

		ClientAnchor anchor = createHelper.createClientAnchor();
		Comment comment = drawingPatriarch.createCellComment(anchor);

Funily it worked for a long time with the same code, but suddenly stopped working a few days ago with updated data.

This is similar to Bug 48803, but I think it may be different than this issue as it happens with different version and functionality involved.

Bug 50696 also talks about trouble with comments, but there it states that it happens when an existing file is changed, however here I am working on a new file each time.

I will attach the file that works and the one that does not work. I can not easily extract a standalone testcase for this, let me know if you need one so I spend the time only if necessary.
Comment 1 Dominik Stadler 2011-08-18 11:20:02 UTC
Created attachment 27404 [details]
Same content without comments works fine
Comment 2 bmckenzie 2011-08-22 16:34:02 UTC
FYI, the same thing happens when using POI 3.8 beta 3 with Excel 2007.
Comment 3 bmckenzie 2011-08-22 16:36:12 UTC
Also, a previous version (3.5 beta 4) did not have this same issue.
Comment 4 Dominik Stadler 2011-08-23 06:26:26 UTC
I just noticed another thing here: I have the application in use for half a year without this problem, but it did start to happen a few days ago without changes to the code. Therefore it seems that the latest Office Service Pack changed Excel so it runs additional checks which lead to the error now.
Comment 5 Evgeniy Berlog 2012-08-15 20:21:18 UTC
This problem should be fixed in trunk.

Please try with a nightly build - see download links on http://poi.apache.org/
or build yourself from SVN trunk, see http://poi.apache.org/subversion.html