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;
}
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();
}
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);
}
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 });
}
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;
}
Aggregations