org.apache.poi.hssf.eventusermodel
public class: EventWorkbookBuilder [javadoc |
source]
java.lang.Object
org.apache.poi.hssf.eventusermodel.EventWorkbookBuilder
When working with the EventUserModel, if you want to
process formulas, you need an instance of
Workbook to pass to a
HSSFWorkbook ,
to finally give to
HSSFFormulaParser ,
and this will build you stub ones.
Since you're working with the EventUserModel, you
wouldn't want to get a full
Workbook and
HSSFWorkbook , as they would eat too much memory.
Instead, you should collect a few key records as they
go past, then call this once you have them to build a
stub
Workbook , and from that a stub
HSSFWorkbook , to use with the
HSSFFormulaParser .
The records you should collect are:
*
ExternSheetRecord
*
BoundSheetRecord
You should probably also collect
SSTRecord ,
but it's not required to pass this in.
To help, this class includes a HSSFListener wrapper
that will do the collecting for you.
| Nested Class Summary: |
|---|
| public static class | EventWorkbookBuilder.SheetRecordCollectingListener | A wrapping HSSFListener which will collect
{@link BoundSheetRecord}s and {@link ExternSheetRecord}s as
they go past, so you can create a Stub {@link Workbook} from
them once required. |
| Method from org.apache.poi.hssf.eventusermodel.EventWorkbookBuilder Detail: |
public static HSSFWorkbook createStubHSSFWorkbook(Workbook workbook) {
return new StubHSSFWorkbook(workbook);
}
|
public static Workbook createStubWorkbook(ExternSheetRecord[] externs,
BoundSheetRecord[] bounds) {
return createStubWorkbook(externs, bounds, null);
}
Creates a stub workbook from the supplied records,
suitable for use with the HSSFFormulaParser |
public static Workbook createStubWorkbook(ExternSheetRecord[] externs,
BoundSheetRecord[] bounds,
SSTRecord sst) {
List wbRecords = new ArrayList();
// Core Workbook records go first
if(bounds != null) {
for(int i=0; i< bounds.length; i++) {
wbRecords.add(bounds[i]);
}
}
if(sst != null) {
wbRecords.add(sst);
}
// Now we can have the ExternSheetRecords,
// preceded by a SupBookRecord
if(externs != null) {
wbRecords.add(SupBookRecord.createInternalReferences(
(short)externs.length));
for(int i=0; i< externs.length; i++) {
wbRecords.add(externs[i]);
}
}
// Finally we need an EoF record
wbRecords.add(EOFRecord.instance);
return Workbook.createWorkbook(wbRecords);
}
Creates a stub Workbook from the supplied records,
suitable for use with the HSSFFormulaParser |