Index: trunk/src/java/org/apache/poi/hssf/eventusermodel/MissingRecordAwareHSSFListener.java =================================================================== --- trunk/src/java/org/apache/poi/hssf/eventusermodel/MissingRecordAwareHSSFListener.java (revision 688113) +++ trunk/src/java/org/apache/poi/hssf/eventusermodel/MissingRecordAwareHSSFListener.java (working copy) @@ -33,6 +33,7 @@ import org.apache.poi.hssf.record.RKRecord; import org.apache.poi.hssf.record.Record; import org.apache.poi.hssf.record.RowRecord; +import org.apache.poi.hssf.record.SharedFormulaRecord; /** *

A HSSFListener which tracks rows and columns, and will @@ -68,7 +69,8 @@ public void processRecord(Record record) { int thisRow = -1; int thisColumn = -1; - + boolean ignoreRecord = false; + switch (record.getSid()) { // the BOFRecord can represent either the beginning of a sheet or the workbook @@ -129,6 +131,12 @@ thisRow = frec.getRow(); thisColumn = frec.getColumn(); break; + case SharedFormulaRecord.sid: + // Fix issue with LastCellOfRowDummyRecord events being returned incorrectly when a + // SharedFormulaRecord is processed. + // Shared formula records should be ignored in the MissingRecordAwareHSSFListener + ignoreRecord = true; + break; case LabelRecord.sid: LabelRecord lrec = (LabelRecord) record; thisRow = lrec.getRow(); @@ -164,7 +172,8 @@ //System.out.println(record.getClass()); break; } - + if (!ignoreRecord) { + // If we're on cells, and this cell isn't in the same // row as the last one, then fire the // dummy end-of-row records? @@ -211,5 +220,6 @@ } childListener.processRecord(record); + } } }