From f16296111b19f6bae2fbb552c282776c2d3af755 Mon Sep 17 00:00:00 2001 From: Nick Burch Date: Wed, 30 Jul 2014 23:06:46 +0000 Subject: [PATCH] Correct logic for the start-of-sheet missing rows, for event user model, and add tests for this git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1614789 13f79535-47bb-0310-9956-ffa450edef68 --- .../MissingRecordAwareHSSFListener.java | 7 +++++-- .../dummyrecord/LastCellOfRowDummyRecord.java | 4 ++++ .../TestMissingRecordAwareHSSFListener.java | 13 ++++++++++++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/java/org/apache/poi/hssf/eventusermodel/MissingRecordAwareHSSFListener.java b/src/java/org/apache/poi/hssf/eventusermodel/MissingRecordAwareHSSFListener.java index ef15ea7ce..503f8d81b 100644 --- a/src/java/org/apache/poi/hssf/eventusermodel/MissingRecordAwareHSSFListener.java +++ b/src/java/org/apache/poi/hssf/eventusermodel/MissingRecordAwareHSSFListener.java @@ -86,7 +86,8 @@ public final class MissingRecordAwareHSSFListener implements HSSFListener { // the workbook case BOFRecord.sid: BOFRecord bof = (BOFRecord) record; - if (bof.getType() == bof.TYPE_WORKBOOK || bof.getType() == bof.TYPE_WORKSHEET) { + if (bof.getType() == BOFRecord.TYPE_WORKBOOK || + bof.getType() == BOFRecord.TYPE_WORKSHEET) { // Reset the row and column counts - new workbook / worksheet resetCounts(); } @@ -106,6 +107,7 @@ public final class MissingRecordAwareHSSFListener implements HSSFListener { // Record this as the last row we saw lastRowRow = rowrec.getRowNumber(); + lastCellColumn = -1; break; case SharedFormulaRecord.sid: @@ -144,7 +146,8 @@ public final class MissingRecordAwareHSSFListener implements HSSFListener { // 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 - if(thisRow != lastCellRow && lastCellRow > -1) { + if(thisRow != lastCellRow && thisRow > 0) { + if (lastCellRow == -1) lastCellRow = 0; for(int i=lastCellRow; i