use of org.apache.poi.hssf.record.RowRecord in project poi by apache.
the class TestRowRecordsAggregate method testRowGet.
@Test
public void testRowGet() {
RowRecordsAggregate rra = new RowRecordsAggregate();
RowRecord rr = new RowRecord(4);
rra.insertRow(rr);
rra.insertRow(new RowRecord(1));
RowRecord rr1 = rra.getRow(4);
assertNotNull(rr1);
assertEquals("Row number is 1", 4, rr1.getRowNumber());
assertTrue("Row record retrieved is identical ", rr1 == rr);
}
use of org.apache.poi.hssf.record.RowRecord in project poi by apache.
the class TestRowBlocksReader method testAbnormalPivotTableRecords_bug46280.
@Test
public void testAbnormalPivotTableRecords_bug46280() {
int SXVIEW_SID = ViewDefinitionRecord.sid;
Record[] inRecs = { new RowRecord(0), new NumberRecord(), // normally MSODRAWING(0x00EC) would come here before SXVIEW
new UnknownRecord(SXVIEW_SID, "dummydata (SXVIEW: View Definition)".getBytes(LocaleUtil.CHARSET_1252)), new WindowTwoRecord() };
RecordStream rs = new RecordStream(Arrays.asList(inRecs), 0);
RowBlocksReader rbr = new RowBlocksReader(rs);
if (rs.peekNextClass() == WindowTwoRecord.class) {
// Should have stopped at the SXVIEW record
fail("Identified bug 46280b");
}
RecordStream rbStream = rbr.getPlainRecordStream();
assertEquals(inRecs[0], rbStream.getNext());
assertEquals(inRecs[1], rbStream.getNext());
assertFalse(rbStream.hasNext());
assertTrue(rs.hasNext());
assertEquals(inRecs[2], rs.getNext());
assertEquals(inRecs[3], rs.getNext());
}
use of org.apache.poi.hssf.record.RowRecord in project poi by apache.
the class TestSheet method testGutsRecord_bug45640.
/**
* Checks for bug introduced around r682282-r683880 that caused a second GUTS records
* which in turn got the dimensions record out of alignment
*/
@Test
public void testGutsRecord_bug45640() {
InternalSheet sheet = InternalSheet.createSheet();
sheet.addRow(new RowRecord(0));
sheet.addRow(new RowRecord(1));
sheet.groupRowRange(0, 1, true);
sheet.toString();
List<RecordBase> recs = sheet.getRecords();
int count = 0;
for (int i = 0; i < recs.size(); i++) {
if (recs.get(i) instanceof GutsRecord) {
count++;
}
}
if (count == 2) {
throw new AssertionFailedError("Identified bug 45640");
}
assertEquals(1, count);
}
use of org.apache.poi.hssf.record.RowRecord in project poi by apache.
the class TestSheet method testMissingDims.
/**
* Some apps seem to write files with missing DIMENSION records.
* Excel(2007) tolerates this, so POI should too.
*/
@Test
public void testMissingDims() {
int rowIx = 5;
int colIx = 6;
NumberRecord nr = new NumberRecord();
nr.setRow(rowIx);
nr.setColumn((short) colIx);
nr.setValue(3.0);
List<Record> inRecs = new ArrayList<Record>();
inRecs.add(BOFRecord.createSheetBOF());
inRecs.add(new RowRecord(rowIx));
inRecs.add(nr);
inRecs.add(createWindow2Record());
inRecs.add(EOFRecord.instance);
InternalSheet sheet;
try {
sheet = createSheet(inRecs);
} catch (RuntimeException e) {
if ("DimensionsRecord was not found".equals(e.getMessage())) {
throw new AssertionFailedError("Identified bug 46206");
}
throw e;
}
RecordCollector rv = new RecordCollector();
sheet.visitContainedRecords(rv, rowIx);
Record[] outRecs = rv.getRecords();
assertEquals(8, outRecs.length);
DimensionsRecord dims = (DimensionsRecord) outRecs[5];
assertEquals(rowIx, dims.getFirstRow());
assertEquals(rowIx, dims.getLastRow());
assertEquals(colIx, dims.getFirstCol());
assertEquals(colIx, dims.getLastCol());
}
use of org.apache.poi.hssf.record.RowRecord in project poi by apache.
the class TestSheet method testRowAggregation.
/**
* Makes sure all rows registered for this sheet are aggregated, they were being skipped
*
*/
@Test
public void testRowAggregation() {
List<Record> records = new ArrayList<Record>();
records.add(InternalSheet.createBOF());
records.add(new DimensionsRecord());
records.add(new RowRecord(0));
records.add(new RowRecord(1));
FormulaRecord formulaRecord = new FormulaRecord();
formulaRecord.setCachedResultTypeString();
records.add(formulaRecord);
records.add(new StringRecord());
records.add(new RowRecord(2));
records.add(createWindow2Record());
records.add(EOFRecord.instance);
InternalSheet sheet = createSheet(records);
assertNotNull("Row [2] was skipped", sheet.getRow(2));
}
Aggregations