Made sure all row records for the sheet are aggregated since rows are skipped

if a formula yields a String.
PR: 15062


git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@353095 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Danny Muid 2003-05-09 12:39:08 +00:00
parent 085fe292e3
commit 97fcb16032
3 changed files with 44 additions and 7 deletions

View File

@ -234,17 +234,16 @@ public class Sheet implements Model
}
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 )
{

View File

@ -135,6 +135,9 @@ public class RowRecordsAggregate
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;
@ -154,7 +157,7 @@ public class RowRecordsAggregate
}
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

View File

@ -7,6 +7,8 @@ import java.util.List;
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
@ -119,6 +121,39 @@ public class SheetTest extends TestCase
}
/**
* 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);
}
}