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