Bug 49649

Summary: The class org.apache.poi.hssf.record.XXX needs to define a clone method
Product: POI Reporter: Antti Koskimäki <antti.koskimaki>
Component: HSSFAssignee: POI Developers List <dev>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P2    
Version: 3.7-dev   
Target Milestone: ---   
Hardware: All   
OS: All   
Attachments: Test-code and quick-and-dirty patch for clone exception problem

Description Antti Koskimäki 2010-07-26 12:13:12 UTC
Created attachment 25803 [details]
Test-code and quick-and-dirty patch for clone exception problem

Got exceptions from wb.cloneSheet() method: 

java.lang.RuntimeException: The class org.apache.poi.hssf.record.HeaderFooterRecord needs to define a clone method

java.lang.RuntimeException: The class org.apache.poi.hssf.record.FeatHdrRecord needs to define a clone method

java.lang.RuntimeException: The class org.apache.poi.hssf.record.UserSViewBegin needs to define a clone method

Exceptions are from different excel-files, but problem is common; I used to be able to clone some sheets and with current version poi-3.7-beta2 at SVN r965267 not anymore.

Got some old POI versions hanging around, and all above cases do clone fine with poi-3.6-beta1 at SVN r816626. I think problem was introduced in releases 835183, 894018 and 892468, when corresponding classes were introduced.

Quick-and-dirty solution was to implement clone with cloneViaReserialise. Seems to work, at least.

Attached test-files plus test-code to re-produce problem, as well as patch for quick-and-dirty solution.
Comment 1 Yegor Kozlov 2010-07-28 11:53:26 UTC
Applied in r980102

Yegor