Search in sources :

Example 6 with ContinueRecord

use of org.apache.poi.hssf.record.ContinueRecord in project poi by apache.

the class TestHSSFEventFactory method testWithCrazyContinueRecords.

public void testWithCrazyContinueRecords() throws Exception {
    // Some files have crazy ordering of their continue records
    // Check that we don't break on them (bug #42844)
    HSSFRequest req = new HSSFRequest();
    MockHSSFListener mockListen = new MockHSSFListener();
    req.addListenerForAllRecords(mockListen);
    POIFSFileSystem fs = new POIFSFileSystem(openSample("ContinueRecordProblem.xls"));
    HSSFEventFactory factory = new HSSFEventFactory();
    factory.processWorkbookEvents(req, fs);
    Record[] recs = mockListen.getRecords();
    // Check we got the records
    assertTrue(recs.length > 100);
    // And none of them are continue ones
    for (Record rec : recs) {
        assertFalse(rec instanceof ContinueRecord);
    }
    // Check that the last few records are as we expect
    // (Makes sure we don't accidently skip the end ones)
    int numRec = recs.length;
    assertEquals(DVALRecord.class, recs[numRec - 4].getClass());
    assertEquals(DVRecord.class, recs[numRec - 3].getClass());
    assertEquals(FeatHdrRecord.class, recs[numRec - 2].getClass());
    assertEquals(EOFRecord.class, recs[numRec - 1].getClass());
}
Also used : POIFSFileSystem(org.apache.poi.poifs.filesystem.POIFSFileSystem) Record(org.apache.poi.hssf.record.Record) NumberRecord(org.apache.poi.hssf.record.NumberRecord) EOFRecord(org.apache.poi.hssf.record.EOFRecord) FeatHdrRecord(org.apache.poi.hssf.record.FeatHdrRecord) SelectionRecord(org.apache.poi.hssf.record.SelectionRecord) ContinueRecord(org.apache.poi.hssf.record.ContinueRecord) BoundSheetRecord(org.apache.poi.hssf.record.BoundSheetRecord) WindowTwoRecord(org.apache.poi.hssf.record.WindowTwoRecord) DVALRecord(org.apache.poi.hssf.record.DVALRecord) DVRecord(org.apache.poi.hssf.record.DVRecord) ContinueRecord(org.apache.poi.hssf.record.ContinueRecord)

Aggregations

ContinueRecord (org.apache.poi.hssf.record.ContinueRecord)6 Record (org.apache.poi.hssf.record.Record)6 EOFRecord (org.apache.poi.hssf.record.EOFRecord)5 WindowTwoRecord (org.apache.poi.hssf.record.WindowTwoRecord)5 Test (org.junit.Test)5 EscherContainerRecord (org.apache.poi.ddf.EscherContainerRecord)4 EscherDggRecord (org.apache.poi.ddf.EscherDggRecord)4 EscherRecord (org.apache.poi.ddf.EscherRecord)4 DrawingRecord (org.apache.poi.hssf.record.DrawingRecord)4 EscherAggregate (org.apache.poi.hssf.record.EscherAggregate)4 NoteRecord (org.apache.poi.hssf.record.NoteRecord)4 ObjRecord (org.apache.poi.hssf.record.ObjRecord)4 RecordBase (org.apache.poi.hssf.record.RecordBase)4 TextObjectRecord (org.apache.poi.hssf.record.TextObjectRecord)4 RowRecordsAggregate (org.apache.poi.hssf.record.aggregates.RowRecordsAggregate)4 HSSFSheet (org.apache.poi.hssf.usermodel.HSSFSheet)4 HSSFWorkbook (org.apache.poi.hssf.usermodel.HSSFWorkbook)4 NumberRecord (org.apache.poi.hssf.record.NumberRecord)2 RecordStream (org.apache.poi.hssf.model.RecordStream)1 ArrayRecord (org.apache.poi.hssf.record.ArrayRecord)1