Bug 45682 - HSSFWorkbook cloneSheet fails for sheets with conditional formatting.
Summary: HSSFWorkbook cloneSheet fails for sheets with conditional formatting.
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: unspecified
Hardware: PC Windows XP
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-08-25 00:26 UTC by Antti Koskimäki
Modified: 2008-08-25 12:01 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Antti Koskimäki 2008-08-25 00:26:41 UTC
HSSFWorkbook cloneSheet fails for sheets containing conditional formattings. 

Reproduced with 3.1-FINAL-20080629 as well as with latest devel from svn (3.2-aplha1) 20080825. Seems to introduced with conditional formating changes, as sheets are cloned correctly with 3.0.2-FINAL-20080204. Stack-trace from latest SVN.


Exception in thread "main" java.lang.RuntimeException: The class org.apache.poi.hssf.record.aggregates.CFRecordsAggregate needs to define a clone method
	at org.apache.poi.hssf.record.Record.clone(Record.java:135)
	at org.apache.poi.hssf.model.Sheet$RecordCloner.visitRecord(Sheet.java:355)
	at org.apache.poi.hssf.record.aggregates.ConditionalFormattingTable.visitContainedRecords(ConditionalFormattingTable.java:56)
	at org.apache.poi.hssf.model.Sheet.cloneSheet(Sheet.java:371)
	at org.apache.poi.hssf.usermodel.HSSFSheet.cloneSheet(HSSFSheet.java:127)
	at org.apache.poi.hssf.usermodel.HSSFWorkbook.cloneSheet(HSSFWorkbook.java:672)
Comment 1 Josh Micich 2008-08-25 01:33:18 UTC
Fixed in svn r688655

junit added
Comment 2 Antti Koskimäki 2008-08-25 04:02:45 UTC
Thanks. Verified that mentioned bug got fixed. 

But at the same time my POI-created conditional formats broke between r688654 and r688655. Excel says "file error, data may have been lost" when opening and all POI-generated conditional formats are missing. This doesn't depend on cloning.
Comment 3 Josh Micich 2008-08-25 12:01:19 UTC
(In reply to comment #2)
> 
> But at the same time my POI-created conditional formats broke between r688654
> and r688655. Excel says "file error, data may have been lost" when opening and
> all POI-generated conditional formats are missing.

Fixed in svn r688825.

CFHeaderRecord wasn't being properly updated with the number of rules.  junit added to cover this logic too.