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)
Fixed in svn r688655 junit added
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.
(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.