Summary: | POI does not work when run the method "cloneSheet()" | ||
---|---|---|---|
Product: | POI | Reporter: | chos xiaonan <xueyunpiaopiao> |
Component: | HSSF | Assignee: | 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
Please upload the problem spreadsheet. Without the file we can't do much. Regards, Yegor Created 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 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)
Sorry for multiple posts. 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? Yes, it is correct. Record is an abstract class, it's clone() method is redefined by concrete subclasses. Yegor |