Search in sources :

Example 1 with BOFRecord

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

the class InternalSheet method createBOF.

/**
     * creates the BOF record
     */
/* package */
static BOFRecord createBOF() {
    BOFRecord retval = new BOFRecord();
    retval.setVersion((short) 0x600);
    retval.setType((short) 0x010);
    retval.setBuild((short) 0x0dbb);
    retval.setBuildYear((short) 1996);
    retval.setHistoryBitMask(0xc1);
    retval.setRequiredVersion(0x6);
    return retval;
}
Also used : BOFRecord(org.apache.poi.hssf.record.BOFRecord)

Example 2 with BOFRecord

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

the class OldExcelExtractor method prepare.

private void prepare() {
    if (!ris.hasNextRecord()) {
        throw new IllegalArgumentException("File contains no records!");
    }
    ris.nextRecord();
    // Work out what version we're dealing with
    int bofSid = ris.getSid();
    switch(bofSid) {
        case BOFRecord.biff2_sid:
            biffVersion = 2;
            break;
        case BOFRecord.biff3_sid:
            biffVersion = 3;
            break;
        case BOFRecord.biff4_sid:
            biffVersion = 4;
            break;
        case BOFRecord.biff5_sid:
            biffVersion = 5;
            break;
        default:
            throw new IllegalArgumentException("File does not begin with a BOF, found sid of " + bofSid);
    }
    // Get the type
    BOFRecord bof = new BOFRecord(ris);
    fileType = bof.getType();
}
Also used : BOFRecord(org.apache.poi.hssf.record.BOFRecord)

Example 3 with BOFRecord

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

the class TestSheet method testCreateSheet.

@Test
public void testCreateSheet() {
    // Check we're adding row and cell aggregates
    List<Record> records = new ArrayList<Record>();
    records.add(BOFRecord.createSheetBOF());
    records.add(new DimensionsRecord());
    records.add(createWindow2Record());
    records.add(EOFRecord.instance);
    InternalSheet sheet = createSheet(records);
    Record[] outRecs = getSheetRecords(sheet, 0);
    int pos = 0;
    assertTrue(outRecs[pos++] instanceof BOFRecord);
    assertTrue(outRecs[pos++] instanceof IndexRecord);
    assertTrue(outRecs[pos++] instanceof DimensionsRecord);
    assertTrue(outRecs[pos++] instanceof WindowTwoRecord);
    assertTrue(outRecs[pos++] instanceof EOFRecord);
}
Also used : EOFRecord(org.apache.poi.hssf.record.EOFRecord) 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) BOFRecord(org.apache.poi.hssf.record.BOFRecord) WindowTwoRecord(org.apache.poi.hssf.record.WindowTwoRecord) IndexRecord(org.apache.poi.hssf.record.IndexRecord) Test(org.junit.Test)

Example 4 with BOFRecord

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

the class TestSanityChecker method testCheckRecordOrder.

@Test
public void testCheckRecordOrder() {
    final SanityChecker c = new SanityChecker();
    List<Record> records = new ArrayList<Record>();
    records.add(new BOFRecord());
    records.add(INTERFACEHDR);
    records.add(createBoundSheetRec());
    records.add(EOFRecord.instance);
    CheckRecord[] check = { new CheckRecord(BOFRecord.class, '1'), new CheckRecord(InterfaceHdrRecord.class, '0'), new CheckRecord(BoundSheetRecord.class, 'M'), new CheckRecord(NameRecord.class, '*'), new CheckRecord(EOFRecord.class, '1') };
    // check pass
    c.checkRecordOrder(records, check);
    records.add(2, createBoundSheetRec());
    c.checkRecordOrder(records, check);
    // optional record missing
    records.remove(1);
    c.checkRecordOrder(records, check);
    records.add(3, new NameRecord());
    // optional multiple record occurs more than one time
    records.add(3, new NameRecord());
    c.checkRecordOrder(records, check);
    // check fail
    confirmBadRecordOrder(check, new Record[] { new BOFRecord(), createBoundSheetRec(), INTERFACEHDR, EOFRecord.instance });
    confirmBadRecordOrder(check, new Record[] { new BOFRecord(), INTERFACEHDR, createBoundSheetRec(), INTERFACEHDR, EOFRecord.instance });
    confirmBadRecordOrder(check, new Record[] { new BOFRecord(), createBoundSheetRec(), new NameRecord(), EOFRecord.instance, new NameRecord() });
    confirmBadRecordOrder(check, new Record[] { INTERFACEHDR, createBoundSheetRec(), EOFRecord.instance });
    confirmBadRecordOrder(check, new Record[] { new BOFRecord(), INTERFACEHDR, EOFRecord.instance });
    confirmBadRecordOrder(check, new Record[] { INTERFACEHDR, createBoundSheetRec(), new BOFRecord(), EOFRecord.instance });
    confirmBadRecordOrder(check, new Record[] { new BOFRecord(), createBoundSheetRec(), INTERFACEHDR, EOFRecord.instance });
}
Also used : CheckRecord(org.apache.poi.hssf.usermodel.SanityChecker.CheckRecord) NameRecord(org.apache.poi.hssf.record.NameRecord) EOFRecord(org.apache.poi.hssf.record.EOFRecord) InterfaceHdrRecord(org.apache.poi.hssf.record.InterfaceHdrRecord) ArrayList(java.util.ArrayList) BoundSheetRecord(org.apache.poi.hssf.record.BoundSheetRecord) InterfaceHdrRecord(org.apache.poi.hssf.record.InterfaceHdrRecord) Record(org.apache.poi.hssf.record.Record) CheckRecord(org.apache.poi.hssf.usermodel.SanityChecker.CheckRecord) BOFRecord(org.apache.poi.hssf.record.BOFRecord) EOFRecord(org.apache.poi.hssf.record.EOFRecord) NameRecord(org.apache.poi.hssf.record.NameRecord) BOFRecord(org.apache.poi.hssf.record.BOFRecord) BoundSheetRecord(org.apache.poi.hssf.record.BoundSheetRecord) Test(org.junit.Test)

Example 5 with BOFRecord

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

the class HSSFChart method createBOFRecord.

private BOFRecord createBOFRecord() {
    BOFRecord r = new BOFRecord();
    r.setVersion((short) 600);
    r.setType((short) 20);
    r.setBuild((short) 0x1CFE);
    r.setBuildYear((short) 1997);
    r.setHistoryBitMask(0x40C9);
    r.setRequiredVersion(106);
    return r;
}
Also used : BOFRecord(org.apache.poi.hssf.record.BOFRecord)

Aggregations

BOFRecord (org.apache.poi.hssf.record.BOFRecord)13 EOFRecord (org.apache.poi.hssf.record.EOFRecord)6 Record (org.apache.poi.hssf.record.Record)4 NoteRecord (org.apache.poi.hssf.record.NoteRecord)3 StringRecord (org.apache.poi.hssf.record.StringRecord)3 Test (org.junit.Test)3 ArrayList (java.util.ArrayList)2 LastCellOfRowDummyRecord (org.apache.poi.hssf.eventusermodel.dummyrecord.LastCellOfRowDummyRecord)2 MissingCellDummyRecord (org.apache.poi.hssf.eventusermodel.dummyrecord.MissingCellDummyRecord)2 BlankRecord (org.apache.poi.hssf.record.BlankRecord)2 ContinueRecord (org.apache.poi.hssf.record.ContinueRecord)2 FormulaRecord (org.apache.poi.hssf.record.FormulaRecord)2 MulBlankRecord (org.apache.poi.hssf.record.MulBlankRecord)2 NumberRecord (org.apache.poi.hssf.record.NumberRecord)2 RecordBase (org.apache.poi.hssf.record.RecordBase)2 RowRecord (org.apache.poi.hssf.record.RowRecord)2 UncalcedRecord (org.apache.poi.hssf.record.UncalcedRecord)2 UnknownRecord (org.apache.poi.hssf.record.UnknownRecord)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 Calendar (java.util.Calendar)1