Search in sources :

Example 16 with RowRecord

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);
}
Also used : MulBlankRecord(org.apache.poi.hssf.record.MulBlankRecord) BlankRecord(org.apache.poi.hssf.record.BlankRecord) CellValueRecordInterface(org.apache.poi.hssf.record.CellValueRecordInterface) RowRecord(org.apache.poi.hssf.record.RowRecord) AssertionFailedError(junit.framework.AssertionFailedError) Test(org.junit.Test)

Example 17 with RowRecord

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());
}
Also used : RowRecord(org.apache.poi.hssf.record.RowRecord) MergeCellsRecord(org.apache.poi.hssf.record.MergeCellsRecord) ArrayList(java.util.ArrayList) StringRecord(org.apache.poi.hssf.record.StringRecord) GutsRecord(org.apache.poi.hssf.record.GutsRecord) MergeCellsRecord(org.apache.poi.hssf.record.MergeCellsRecord) DrawingRecord(org.apache.poi.hssf.record.DrawingRecord) NoteRecord(org.apache.poi.hssf.record.NoteRecord) Record(org.apache.poi.hssf.record.Record) ObjRecord(org.apache.poi.hssf.record.ObjRecord) EOFRecord(org.apache.poi.hssf.record.EOFRecord) RowRecord(org.apache.poi.hssf.record.RowRecord) ColumnInfoRecord(org.apache.poi.hssf.record.ColumnInfoRecord) WindowTwoRecord(org.apache.poi.hssf.record.WindowTwoRecord) EscherDggRecord(org.apache.poi.ddf.EscherDggRecord) TextObjectRecord(org.apache.poi.hssf.record.TextObjectRecord) IndexRecord(org.apache.poi.hssf.record.IndexRecord) BOFRecord(org.apache.poi.hssf.record.BOFRecord) NumberRecord(org.apache.poi.hssf.record.NumberRecord) MulBlankRecord(org.apache.poi.hssf.record.MulBlankRecord) UncalcedRecord(org.apache.poi.hssf.record.UncalcedRecord) DimensionsRecord(org.apache.poi.hssf.record.DimensionsRecord) BlankRecord(org.apache.poi.hssf.record.BlankRecord) FormulaRecord(org.apache.poi.hssf.record.FormulaRecord) DimensionsRecord(org.apache.poi.hssf.record.DimensionsRecord) CellRangeAddress(org.apache.poi.ss.util.CellRangeAddress) Test(org.junit.Test)

Aggregations

RowRecord (org.apache.poi.hssf.record.RowRecord)17 Test (org.junit.Test)11 BlankRecord (org.apache.poi.hssf.record.BlankRecord)7 DimensionsRecord (org.apache.poi.hssf.record.DimensionsRecord)7 MulBlankRecord (org.apache.poi.hssf.record.MulBlankRecord)7 Record (org.apache.poi.hssf.record.Record)7 GutsRecord (org.apache.poi.hssf.record.GutsRecord)6 NumberRecord (org.apache.poi.hssf.record.NumberRecord)6 WindowTwoRecord (org.apache.poi.hssf.record.WindowTwoRecord)6 BOFRecord (org.apache.poi.hssf.record.BOFRecord)5 DrawingRecord (org.apache.poi.hssf.record.DrawingRecord)5 FormulaRecord (org.apache.poi.hssf.record.FormulaRecord)5 NoteRecord (org.apache.poi.hssf.record.NoteRecord)5 StringRecord (org.apache.poi.hssf.record.StringRecord)5 AssertionFailedError (junit.framework.AssertionFailedError)4 EscherDggRecord (org.apache.poi.ddf.EscherDggRecord)4 CellValueRecordInterface (org.apache.poi.hssf.record.CellValueRecordInterface)4 ColumnInfoRecord (org.apache.poi.hssf.record.ColumnInfoRecord)4 EOFRecord (org.apache.poi.hssf.record.EOFRecord)4 IndexRecord (org.apache.poi.hssf.record.IndexRecord)4