Bug 45859 - cloneSheet corrupts workbook with picture
Summary: cloneSheet corrupts workbook with picture
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 3.2-dev
Hardware: PC Windows XP
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2008-09-22 06:17 UTC by Antti Koskimäki
Modified: 2008-09-30 07:31 UTC (History)
0 users

source and excel to re-produce the bug (19.33 KB, application/zip)
2008-09-22 06:17 UTC, Antti Koskimäki

Note You need to log in before you can comment on or make changes to this bug.
Description Antti Koskimäki 2008-09-22 06:17:27 UTC
Created attachment 22622 [details]
source and excel to re-produce the bug

I ran into mysterious workbook corrupts with recent POI releases. When opening the workbook, excel (2003) complains

"File error, data may have been lost". After repairs all the formatting and pictures seem to be lost.

I could narrow down the problem to

1) several cloneSheet operations
2) one worksheet having picture in it (not the cloned one)

See the attachment for excel and source to re-produce.

Removing the picture helps, and with single cloneSheet it works. Not all pictures trigger the corrupt, and excel feedback varies based on picture too; with some pictures I'll get multiple "File error" boxes, one for every sheet. Or just one error box, like in attaced case.

Tested with several releases; r696898 (broken), r693085 (broken), r692893 (works), 3.1-FINAL (works) and 3.0.2-FINAL (works)
Comment 1 Antti Koskimäki 2008-09-22 06:23:41 UTC
Actually, it seems that change in release 693085 have caused the corruption; tested reverting the change with latest r697599 and my test case does not corrupt anymore.

Maybe someone with "deeper understanding" would verify?
Comment 2 Yegor Kozlov 2008-09-30 07:31:49 UTC
I moved workbook.cloneDrawings back in the brackets. 

Actually, the change in r693085 was intentional. Having cloneDrawings  in the brackets would mean that the drawing stuff is cloned ONLY if the sheet has data validation. In fact, we should clone drawings regardless if DV is present or not.

I expect that other bugs related to this one will pop up in future.