use of org.apache.poi.hssf.record.RowRecord in project poi by apache.
the class TestSheet method testRowValueAggregatesOrder_bug45145.
/**
* Prior to bug 45145 <tt>RowRecordsAggregate</tt> and <tt>ValueRecordsAggregate</tt> could
* sometimes occur in reverse order. This test reproduces one of those situations and makes
* sure that RRA comes before VRA.<br/>
*
* The code here represents a normal POI use case where a spreadsheet is created from scratch.
*/
@Test
public void testRowValueAggregatesOrder_bug45145() {
InternalSheet sheet = InternalSheet.createSheet();
RowRecord rr = new RowRecord(5);
sheet.addRow(rr);
CellValueRecordInterface cvr = new BlankRecord();
cvr.setColumn((short) 0);
cvr.setRow(5);
sheet.addValueRecord(5, cvr);
int dbCellRecordPos = getDbCellRecordPos(sheet);
if (dbCellRecordPos == 252) {
// DBCELL record pos is calculated wrong if VRA comes before RRA
throw new AssertionFailedError("Identified bug 45145");
}
// if (false) {
// // make sure that RRA and VRA are in the right place
// // (Aug 2008) since the VRA is now part of the RRA, there is much less chance that
// // they could get out of order. Still, one could write serialize the sheet here,
// // and read back with EventRecordFactory to make sure...
// }
assertEquals(242, dbCellRecordPos);
}
use of org.apache.poi.hssf.record.RowRecord in project poi by apache.
the class TestSheet method testMovingMergedRegion.
/**
* Bug: 22922 (Reported by Xuemin Guan)
* <p>
* Remove mergedregion fails when a sheet loses records after an initial CreateSheet
* fills up the records.
*
*/
@Test
public void testMovingMergedRegion() {
List<Record> records = new ArrayList<Record>();
CellRangeAddress[] cras = { new CellRangeAddress(0, 1, 0, 2) };
MergeCellsRecord merged = new MergeCellsRecord(cras, 0, cras.length);
records.add(BOFRecord.createSheetBOF());
records.add(new DimensionsRecord());
records.add(new RowRecord(0));
records.add(new RowRecord(1));
records.add(new RowRecord(2));
records.add(createWindow2Record());
records.add(EOFRecord.instance);
records.add(merged);
InternalSheet sheet = createSheet(records);
// TODO - what does this line do?
sheet.getRecords().remove(0);
//stub object to throw off list INDEX operations
sheet.removeMergedRegion(0);
assertEquals("Should be no more merged regions", 0, sheet.getNumMergedRegions());
}
Aggregations