Summary: | HSSFWorkbook.cloneSheet after createDrawingPatriarch -> Exception | ||
---|---|---|---|
Product: | POI | Reporter: | olivier.masseau |
Component: | HSSF | Assignee: | POI Developers List <dev> |
Status: | RESOLVED FIXED | ||
Severity: | normal | ||
Priority: | P2 | ||
Version: | 3.6-FINAL | ||
Target Milestone: | --- | ||
Hardware: | PC | ||
OS: | Windows XP | ||
Attachments: |
Excel workbook used to reproduce the bug.
Fixed bug with cloning empty EscherAggregate records |
Created attachment 28512 [details]
Fixed bug with cloning empty EscherAggregate records
Bug appears only if sheet has no drawing records. If we try to serialize empty EscherRecord it returns empty bytes array what can cause exceptions.
|
Created attachment 25668 [details] Excel workbook used to reproduce the bug. If I open an existing workbook with one sheet and then create a drawing patriarch for the sheet, I cannot clone the sheet anymore. Simple code to reproduce the bug : public static void main(String[] args) { try { Workbook workbook = WorkbookFactory.create(new FileInputStream("C:\\test.xls")); workbook.getSheetAt(0).createDrawingPatriarch(); workbook.cloneSheet(0); System.out.println("OK"); } catch(Exception e) { e.printStackTrace(); } } It produces this exception : java.lang.IllegalStateException: EOF - next record not available at org.apache.poi.hssf.record.RecordInputStream.nextRecord(RecordInputStream.java:190) at org.apache.poi.hssf.record.Record.cloneViaReserialise(Record.java:88) at org.apache.poi.hssf.record.AbstractEscherHolderRecord.clone(AbstractEscherHolderRecord.java:150) at org.apache.poi.hssf.model.Sheet.cloneSheet(Sheet.java:375) at org.apache.poi.hssf.usermodel.HSSFSheet.cloneSheet(HSSFSheet.java:121) at org.apache.poi.hssf.usermodel.HSSFWorkbook.cloneSheet(HSSFWorkbook.java:662) at org.apache.poi.hssf.usermodel.HSSFWorkbook.cloneSheet(HSSFWorkbook.java:87)