Summary: | org.apache.poi.hssf.record.RecordFormatException at BOF record | ||
---|---|---|---|
Product: | POI | Reporter: | Tomas Vehovsky <easy> |
Component: | HSSF | Assignee: | POI Developers List <dev> |
Status: | RESOLVED DUPLICATE | ||
Severity: | normal | ||
Priority: | P2 | ||
Version: | 3.0-FINAL | ||
Target Milestone: | --- | ||
Hardware: | Other | ||
OS: | Windows 2000 |
Description
Tomas Vehovsky
2007-09-17 08:18:51 UTC
Do you happen to know what version of excel (and even if it was excel) produced the file? Before adding in patches to skip records, it'd be good to know how common it's likely to be. Also, we normally like to add unit tests, so ideally we'll want an example of a problem file. Any chance you could edit out the sensitive data, and upload? The file was produced by other external tool (not by Excel itself). Unfortunately, I cannot cut-out sensitive data because once I open and save the document in MS Excel then the BOF record inside the document is changed (fixed) and document can be opened by POI. BOF record of the problematic document looks like this: Record identifier: 0809h ==> BIFF5-8 Offset (Length) Value: 0 (2) 0600h ==> BIFF8 Offset (Length) Value: 2 (2) 0005h ==> Workbook globals Offset (Length) Value: 4 (2) 09D7h Offset (Length) Value: 6 (2) 07CBh It's obvious that this is non-Excel record but record written by external tool. See for example Excel File Format description http://sc.openoffice.org/excelfileformat.pdf (chapters 5.8.1 and 5.8.2). If POI is supposed to accept not only Excel XLS files but XLS files written by external tools as well, then it should be able to allow (but ignore) optional fields in BOF record. Some kind of solution for non standard BOF record is mentioned here http://mail-archives.apache.org/mod_mbox/poi-dev/200706.mbox/%3C466DA1B3.5050006@admadic.de%3E ... protected void fillFields(RecordInputStream in) { field_1_version = in.readShort(); field_2_type = in.readShort(); if (in.getRecordOffset()<in.getLength()) field_3_build = in.readShort(); if (in.getRecordOffset()<in.getLength()) field_4_year = in.readShort(); if (in.getRecordOffset()<in.getLength()) field_5_history = in.readInt(); if (in.getRecordOffset()<in.getLength()) field_6_rversion = in.readInt(); } ... |