Search in sources :

Example 1 with SupBookRecord

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

the class EventWorkbookBuilder method createStubWorkbook.

/**
	 * Creates a stub Workbook from the supplied records,
	 *  suitable for use with the {@link HSSFFormulaParser}
	 * @param externs The ExternSheetRecords in your file
	 * @param bounds The BoundSheetRecords in your file
	 * @param sst The SSTRecord in your file.
	 * @return A stub Workbook suitable for use with {@link HSSFFormulaParser}
	 */
public static InternalWorkbook createStubWorkbook(ExternSheetRecord[] externs, BoundSheetRecord[] bounds, SSTRecord sst) {
    List<Record> wbRecords = new ArrayList<Record>();
    // Core Workbook records go first
    if (bounds != null) {
        for (BoundSheetRecord bound : bounds) {
            wbRecords.add(bound);
        }
    }
    if (sst != null) {
        wbRecords.add(sst);
    }
    //  preceded by a SupBookRecord
    if (externs != null) {
        wbRecords.add(SupBookRecord.createInternalReferences((short) externs.length));
        for (ExternSheetRecord extern : externs) {
            wbRecords.add(extern);
        }
    }
    // Finally we need an EoF record
    wbRecords.add(EOFRecord.instance);
    return InternalWorkbook.createWorkbook(wbRecords);
}
Also used : ExternSheetRecord(org.apache.poi.hssf.record.ExternSheetRecord) ArrayList(java.util.ArrayList) BoundSheetRecord(org.apache.poi.hssf.record.BoundSheetRecord) Record(org.apache.poi.hssf.record.Record) SupBookRecord(org.apache.poi.hssf.record.SupBookRecord) SSTRecord(org.apache.poi.hssf.record.SSTRecord) EOFRecord(org.apache.poi.hssf.record.EOFRecord) ExternSheetRecord(org.apache.poi.hssf.record.ExternSheetRecord) BoundSheetRecord(org.apache.poi.hssf.record.BoundSheetRecord)

Example 2 with SupBookRecord

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

the class TestSupBookRecord method testLoadIR.

/**
     * tests that we can load the record
     */
public void testLoadIR() {
    SupBookRecord record = new SupBookRecord(TestcaseRecordInputStream.create(0x01AE, dataIR));
    //expected flag
    assertTrue(record.isInternalReferences());
    //expected # of sheets
    assertEquals(0x4, record.getNumberOfSheets());
    //sid+size+data
    assertEquals(8, record.getRecordSize());
}
Also used : SupBookRecord(org.apache.poi.hssf.record.SupBookRecord)

Example 3 with SupBookRecord

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

the class TestSupBookRecord method testLoadAIF.

/**
     * tests that we can load the record
     */
public void testLoadAIF() {
    SupBookRecord record = new SupBookRecord(TestcaseRecordInputStream.create(0x01AE, dataAIF));
    //expected flag
    assertTrue(record.isAddInFunctions());
    //expected # of sheets
    assertEquals(0x1, record.getNumberOfSheets());
    //sid+size+data
    assertEquals(8, record.getRecordSize());
}
Also used : SupBookRecord(org.apache.poi.hssf.record.SupBookRecord)

Example 4 with SupBookRecord

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

the class TestSupBookRecord method testLoadER.

/**
     * tests that we can load the record
     */
public void testLoadER() {
    SupBookRecord record = new SupBookRecord(TestcaseRecordInputStream.create(0x01AE, dataER));
    //expected flag
    assertTrue(record.isExternalReferences());
    //expected # of sheets
    assertEquals(0x2, record.getNumberOfSheets());
    //sid+size+data
    assertEquals(34, record.getRecordSize());
    assertEquals("testURL", record.getURL());
    String[] sheetNames = record.getSheetNames();
    assertEquals(2, sheetNames.length);
    assertEquals("Sheet1", sheetNames[0]);
    assertEquals("Sheet2", sheetNames[1]);
}
Also used : SupBookRecord(org.apache.poi.hssf.record.SupBookRecord)

Example 5 with SupBookRecord

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

the class TestSupBookRecord method testStoreER.

public void testStoreER() {
    String url = "testURL";
    String[] sheetNames = { "Sheet1", "Sheet2" };
    SupBookRecord record = SupBookRecord.createExternalReferences(url, sheetNames);
    TestcaseRecordInputStream.confirmRecordEncoding(0x01AE, dataER, record.serialize());
}
Also used : SupBookRecord(org.apache.poi.hssf.record.SupBookRecord)

Aggregations

SupBookRecord (org.apache.poi.hssf.record.SupBookRecord)13 ExternSheetRecord (org.apache.poi.hssf.record.ExternSheetRecord)3 CountryRecord (org.apache.poi.hssf.record.CountryRecord)2 EOFRecord (org.apache.poi.hssf.record.EOFRecord)2 ExternalNameRecord (org.apache.poi.hssf.record.ExternalNameRecord)2 Record (org.apache.poi.hssf.record.Record)2 NameXPtg (org.apache.poi.ss.formula.ptg.NameXPtg)2 ArrayList (java.util.ArrayList)1 BOFRecord (org.apache.poi.hssf.record.BOFRecord)1 BoundSheetRecord (org.apache.poi.hssf.record.BoundSheetRecord)1 CRNCountRecord (org.apache.poi.hssf.record.CRNCountRecord)1 CRNRecord (org.apache.poi.hssf.record.CRNRecord)1 NameCommentRecord (org.apache.poi.hssf.record.NameCommentRecord)1 NameRecord (org.apache.poi.hssf.record.NameRecord)1 SSTRecord (org.apache.poi.hssf.record.SSTRecord)1