use of org.apache.poi.hssf.record.InterfaceHdrRecord in project poi by apache.
the class InternalWorkbook method createWorkbook.
/**
* Creates an empty workbook object with three blank sheets and all the empty
* fields. Use this to create a workbook from scratch.
*
* @return an empty workbook object
*/
public static InternalWorkbook createWorkbook() {
LOG.log(DEBUG, "creating new workbook from scratch");
InternalWorkbook retval = new InternalWorkbook();
List<Record> records = new ArrayList<Record>(30);
retval.records.setRecords(records);
List<FormatRecord> formats = retval.formats;
records.add(createBOF());
records.add(new InterfaceHdrRecord(CODEPAGE));
records.add(createMMS());
records.add(InterfaceEndRecord.instance);
records.add(createWriteAccess());
records.add(createCodepage());
records.add(createDSF());
records.add(createTabId());
retval.records.setTabpos(records.size() - 1);
records.add(createFnGroupCount());
records.add(createWindowProtect());
records.add(createProtect());
retval.records.setProtpos(records.size() - 1);
records.add(createPassword());
records.add(createProtectionRev4());
records.add(createPasswordRev4());
retval.windowOne = createWindowOne();
records.add(retval.windowOne);
records.add(createBackup());
retval.records.setBackuppos(records.size() - 1);
records.add(createHideObj());
records.add(createDateWindow1904());
records.add(createPrecision());
records.add(createRefreshAll());
records.add(createBookBool());
records.add(createFont());
records.add(createFont());
records.add(createFont());
records.add(createFont());
// last font record position
retval.records.setFontpos(records.size() - 1);
retval.numfonts = 4;
// set up format records
for (int i = 0; i <= 7; i++) {
FormatRecord rec = createFormat(i);
retval.maxformatid = retval.maxformatid >= rec.getIndexCode() ? retval.maxformatid : rec.getIndexCode();
formats.add(rec);
records.add(rec);
}
for (int k = 0; k < 21; k++) {
records.add(InternalWorkbook.createExtendedFormat(k));
retval.numxfs++;
}
retval.records.setXfpos(records.size() - 1);
for (int k = 0; k < 6; k++) {
records.add(InternalWorkbook.createStyle(k));
}
records.add(InternalWorkbook.createUseSelFS());
// now just do 1
int nBoundSheets = 1;
for (int k = 0; k < nBoundSheets; k++) {
BoundSheetRecord bsr = createBoundSheet(k);
records.add(bsr);
retval.boundsheets.add(bsr);
retval.records.setBspos(records.size() - 1);
}
records.add(InternalWorkbook.createCountry());
for (int k = 0; k < nBoundSheets; k++) {
retval.getOrCreateLinkTable().checkExternSheet(k);
}
retval.sst = new SSTRecord();
records.add(retval.sst);
records.add(InternalWorkbook.createExtendedSST());
records.add(EOFRecord.instance);
LOG.log(DEBUG, "exit create new workbook from scratch");
return retval;
}
Aggregations