Bug 46776

Summary: POI does not work when run the method "cloneSheet()"
Product: POI Reporter: chos xiaonan <xueyunpiaopiao>
Component: HSSFAssignee: POI Developers List <dev>
Status: RESOLVED INVALID    
Severity: normal    
Priority: P2    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Attachments: Test Spreadsheet

Description chos xiaonan 2009-02-26 21:27:30 UTC
Version: poi 3.5beta (poi-3.5-beta5-20090219.jar)

Run Source:

workbook = WorkbookFactory.create(new FileInputStream("dd.xls"));
HSSFSheet cloneSheet = workbook.cloneSheet(0);

Error message:
Caused by: java.lang.RuntimeException: The class org.apache.poi.hssf.record.MulBlankRecord needs to define a clone method
	at org.apache.poi.hssf.record.Record.clone(Record.java:71)
	at org.apache.poi.hssf.model.Sheet$RecordCloner.visitRecord(Sheet.java:404)
	at org.apache.poi.hssf.record.aggregates.RecordAggregate$PositionTrackingVisitor.visitRecord(RecordAggregate.java:106)
	at org.apache.poi.hssf.record.aggregates.ValueRecordsAggregate.visitCellsForRow(ValueRecordsAggregate.java:248)
	at org.apache.poi.hssf.record.aggregates.RowRecordsAggregate.visitContainedRecords(RowRecordsAggregate.java:267)
	at org.apache.poi.hssf.model.Sheet.cloneSheet(Sheet.java:420)
	at org.apache.poi.hssf.usermodel.HSSFSheet.cloneSheet(HSSFSheet.java:131)
	at org.apache.poi.hssf.usermodel.HSSFWorkbook.cloneSheet(HSSFWorkbook.java:696)
Comment 1 Yegor Kozlov 2009-04-04 06:05:25 UTC
Please upload the problem spreadsheet.  Without the file we can't do much.

Regards,
Yegor
Comment 2 Yuta Takahashi 2009-04-21 21:37:26 UTC
Created attachment 23525 [details]
Test Spreadsheet
Comment 3 Yuta Takahashi 2009-04-21 21:46:20 UTC
I suppose that I have the same problem. The error occurred when running the method "cloneSheet()" to clone a sheet which contains multiple blank cells (a set of columns in a row with no value but with styling). Please use the attached spreadsheet to reproduce the error.

Version:
  poi 3.5beta (poi-3.5-beta5-20090219.jar)

Run Source:
  Workbook workbook = WorkbookFactory.create(new FileInputStream("Book1.xls"));
  Sheet cloneSheet = workbook.cloneSheet(0);

Error message:
  Exception in thread "main" java.lang.RuntimeException: The class org.apache.poi.hssf.record.MulBlankRecord needs to define a clone method
	at org.apache.poi.hssf.record.Record.clone(Record.java:71)
	at org.apache.poi.hssf.model.Sheet$RecordCloner.visitRecord(Sheet.java:404)
	at org.apache.poi.hssf.record.aggregates.RecordAggregate$PositionTrackingVisitor.visitRecord(RecordAggregate.java:106)
	at org.apache.poi.hssf.record.aggregates.ValueRecordsAggregate.visitCellsForRow(ValueRecordsAggregate.java:248)
	at org.apache.poi.hssf.record.aggregates.RowRecordsAggregate.visitContainedRecords(RowRecordsAggregate.java:267)
	at org.apache.poi.hssf.model.Sheet.cloneSheet(Sheet.java:420)
	at org.apache.poi.hssf.usermodel.HSSFSheet.cloneSheet(HSSFSheet.java:131)
	at org.apache.poi.hssf.usermodel.HSSFWorkbook.cloneSheet(HSSFWorkbook.java:696)
	at org.apache.poi.hssf.usermodel.HSSFWorkbook.cloneSheet(HSSFWorkbook.java:85)
Comment 4 Yuta Takahashi 2009-04-21 21:47:44 UTC
Comment on attachment 23525 [details]
Test Spreadsheet

I suppose that I have the same problem. The error occurred when running the method "cloneSheet()" to clone a sheet which contains multiple blank cells (a set of columns in a row with no value but with styling). Please use the attached spreadsheet to reproduce the error.

Version:
  poi 3.5beta (poi-3.5-beta5-20090219.jar)

Run Source:
  Workbook workbook = WorkbookFactory.create(new FileInputStream("Book1.xls"));
  Sheet cloneSheet = workbook.cloneSheet(0);

Error message:
  Exception in thread "main" java.lang.RuntimeException: The class org.apache.poi.hssf.record.MulBlankRecord needs to define a clone method
	at org.apache.poi.hssf.record.Record.clone(Record.java:71)
	at org.apache.poi.hssf.model.Sheet$RecordCloner.visitRecord(Sheet.java:404)
	at org.apache.poi.hssf.record.aggregates.RecordAggregate$PositionTrackingVisitor.visitRecord(RecordAggregate.java:106)
	at org.apache.poi.hssf.record.aggregates.ValueRecordsAggregate.visitCellsForRow(ValueRecordsAggregate.java:248)
	at org.apache.poi.hssf.record.aggregates.RowRecordsAggregate.visitContainedRecords(RowRecordsAggregate.java:267)
	at org.apache.poi.hssf.model.Sheet.cloneSheet(Sheet.java:420)
	at org.apache.poi.hssf.usermodel.HSSFSheet.cloneSheet(HSSFSheet.java:131)
	at org.apache.poi.hssf.usermodel.HSSFWorkbook.cloneSheet(HSSFWorkbook.java:696)
	at org.apache.poi.hssf.usermodel.HSSFWorkbook.cloneSheet(HSSFWorkbook.java:85)
Comment 5 Yuta Takahashi 2009-04-21 22:29:17 UTC
Sorry for multiple posts.
Comment 6 Josh Micich 2009-06-05 18:02:52 UTC
Fixed in svn r782177

junit added


The functionality probably regressed with this change: r741850

.
Comment 7 swingo71 2009-08-27 22:54:57 UTC
I use poi-3.5-beta6 jar files and
check HSSFWorkbook.cloneSheet() method.
But this BUG was happended yet.

I wonder this Bug is happend in 
org.apache.poi.hssf.record.Record.clone method.

at org.apache.poi.hssf.record.Record.clone
--------
public Object clone() {
    if (false) {
        // TODO - implement clone in a more standardised way
        try {
            return super.clone();
        } catch (CloneNotSupportedException e) {
            throw new RuntimeException(e);
        }
    }
    throw new RuntimeException("The class "+getClass().getName()+" needs to define a clone method");
}
--------
This code seems that throw RuntimeException ALWAYS.
Is it correct?
Comment 8 Yegor Kozlov 2009-08-31 10:21:41 UTC
Yes, it is correct.
Record is an abstract class, it's clone() method is redefined by concrete subclasses. 

Yegor