--- src/java/org/apache/poi/hssf/record/BOFRecord.java (revision 552497) +++ src/java/org/apache/poi/hssf/record/BOFRecord.java (working copy) @@ -29,6 +29,7 @@ * REFERENCE: PG 289 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)

* @author Andrew C. Oliver * @author Jason Height (jheight at chariot dot net dot au) + * @author Richard Evans (richard.evans at datanomic.com) * @version 2.0-pre */ @@ -110,10 +111,24 @@ { field_1_version = in.readShort(); field_2_type = in.readShort(); - field_3_build = in.readShort(); - field_4_year = in.readShort(); - field_5_history = in.readInt(); - field_6_rversion = in.readInt(); + + // Some external tools do not generate all of the remaining fields + + if (in.remaining() >= 2) { + field_3_build = in.readShort(); + } + + if (in.remaining() >= 2) { + field_4_year = in.readShort(); + } + + if (in.remaining() >= 4) { + field_5_history = in.readInt(); + } + + if (in.remaining() >= 4) { + field_6_rversion = in.readInt(); + } } /**