}
else if ( rec.getSid() == RowRecord.sid )
{
+ RowRecord row = (RowRecord)rec;
+ if (!isfirstrow) rec = null; //only add the aggregate once
+
if ( isfirstrow )
{
retval.rows = new RowRecordsAggregate();
- rec = retval.rows;
- retval.rows.construct( k, recs );
+ rec = retval.rows;
isfirstrow = false;
}
- else
- {
- rec = null;
- }
+ retval.rows.insertRow(row);
}
else if ( rec.getSid() == PrintGridlinesRecord.sid )
{
return lastrow;
}
+ /*
+ * No need to go through all the records as we're just collecting RowRecords
+
public int construct(int offset, List records)
{
int k = 0;
}
return k;
}
-
+ */
/**
* called by the class that is responsible for writing this sucker.
* Subclasses should implement this so that their data is passed back in a
import junit.framework.TestCase;
import org.apache.poi.hssf.record.ColumnInfoRecord;
+import org.apache.poi.hssf.record.RowRecord;
+import org.apache.poi.hssf.record.StringRecord;
/**
* @author Tony Poppleton
}
+ /**
+ * Makes sure all rows registered for this sheet are aggregated, they were being skipped
+ *
+ */
+ public void testRowAggregation() {
+ List records = new ArrayList();
+ RowRecord row = new RowRecord();
+ row.setRowNumber(0);
+ records.add(row);
+
+ row = new RowRecord();
+ row.setRowNumber(1);
+ records.add(row);
+
+ records.add(new StringRecord());
+
+ row = new RowRecord();
+ row.setRowNumber(2);
+ records.add(row);
+
+
+ Sheet sheet = Sheet.createSheet(records, 0);
+ assertNotNull("Row [2] was skipped", sheet.getRow(2));
+
+ }
+
+
+ public static void main(String [] args) {
+ System.out
+ .println("Testing : "+SheetTest.class.getName());
+ junit.textui.TestRunner.run(SheetTest.class);
+ }
+
}