Top Description Inners Fields Constructors Methods
org.apache.poi.hssf.extractor

public Class EventBasedExcelExtractor

extends Object
implements POIOLE2TextExtractor, ExcelExtractor
Class Inheritance
All Implemented Interfaces
org.apache.poi.ss.extractor.ExcelExtractor, org.apache.poi.extractor.POIOLE2TextExtractor, org.apache.poi.extractor.POITextExtractor, java.io.Closeable, java.lang.AutoCloseable
Imports
java.io.Closeable, .IOException, java.util.ArrayList, .List, org.apache.poi.POIDocument, org.apache.poi.extractor.POIOLE2TextExtractor, org.apache.poi.hpsf.DocumentSummaryInformation, .SummaryInformation, org.apache.poi.hssf.eventusermodel.FormatTrackingHSSFListener, .HSSFEventFactory, .HSSFListener, .HSSFRequest, org.apache.poi.hssf.model.HSSFFormulaParser, org.apache.poi.hssf.record.BOFRecord, .BoundSheetRecord, .FormulaRecord, .LabelRecord, .LabelSSTRecord, .NoteRecord, .NumberRecord, .SSTRecord, .StringRecord, org.apache.poi.poifs.filesystem.DirectoryEntry, .DirectoryNode, .POIFSFileSystem

A text extractor for Excel files, that is based on the HSSF EventUserModel API. It will typically use less memory than ExcelExtractor, but may not provide the same richness of formatting. Returns the textual content of the file, suitable for indexing by something like Lucene, but not really intended for display to the user.

To turn an excel file into a CSV or similar, then see the XLS2CSVmra example

See Also
XLS2CSVmra

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class

Field Summary

Modifier and TypeField and Description
private final DirectoryNode
pack-priv boolean
pack-priv boolean
private boolean
private final POIFSFileSystem

Constructor Summary

AccessConstructor and Description
public
public

Method Summary

Modifier and TypeMethod and Description
public void
close()

Overrides default org.apache.poi.extractor.POITextExtractor.close.

Allows to free resources of the Extractor as soon as it is not needed any more.

public DocumentSummaryInformation
getDocSummaryInformation()

Overrides default org.apache.poi.extractor.POIOLE2TextExtractor.getDocSummaryInformation.

Would return the document information metadata for the document, if we supported it

public POIDocument
getDocument()

Implements org.apache.poi.extractor.POIOLE2TextExtractor.getDocument.

Return the underlying POIDocument

public Closeable
public DirectoryEntry
getRoot()

Overrides default org.apache.poi.extractor.POIOLE2TextExtractor.getRoot.

Return the underlying DirectoryEntry of this document.

public SummaryInformation
getSummaryInformation()

Overrides default org.apache.poi.extractor.POIOLE2TextExtractor.getSummaryInformation.

Would return the summary information metadata for the document, if we supported it

public String
public boolean
public void
setCloseFilesystem(boolean
true (default), if underlying resources/filesystem should be closed on close()
doCloseFilesystem
)

Implements org.apache.poi.extractor.POITextExtractor.setCloseFilesystem.

public void
setFormulasNotResults(boolean
true if the formula itself is returned
formulasNotResults
)

Implements org.apache.poi.ss.extractor.ExcelExtractor.setFormulasNotResults.

Should we return the formula itself, and not the result it produces?

public void
setIncludeCellComments(boolean
true if cell comments should be included
includeComments
)

Implements org.apache.poi.ss.extractor.ExcelExtractor.setIncludeCellComments.

Would control the inclusion of cell comments from the document, if we supported it

public void
setIncludeHeadersFooters(boolean
true if headers and footers should be included
includeHeadersFooters
)

Implements org.apache.poi.ss.extractor.ExcelExtractor.setIncludeHeadersFooters.

Would control the inclusion of headers and footers from the document, if we supported it

public void
setIncludeSheetNames(boolean
true if the sheet names should be included
includeSheetNames
)

Implements org.apache.poi.ss.extractor.ExcelExtractor.setIncludeSheetNames.

Should sheet names be included?

private EventBasedExcelExtractor.TextListener
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_dirback to summary
private final DirectoryNode _dir
_formulasNotResultsback to summary
pack-priv boolean _formulasNotResults
_includeSheetNamesback to summary
pack-priv boolean _includeSheetNames
doCloseFilesystemback to summary
private boolean doCloseFilesystem
poifsback to summary
private final POIFSFileSystem poifs

Constructor Detail

EventBasedExcelExtractorback to summary
public EventBasedExcelExtractor(DirectoryNode dir)
EventBasedExcelExtractorback to summary
public EventBasedExcelExtractor(POIFSFileSystem fs)

Method Detail

closeback to summary
public void close() throws IOException

Overrides default org.apache.poi.extractor.POITextExtractor.close.

Doc from org.apache.poi.extractor.POITextExtractor.close.

Allows to free resources of the Extractor as soon as it is not needed any more. This may include closing open file handles and freeing memory. The Extractor cannot be used after close has been called.

Annotations
@Override
Exceptions
IOException:

Doc from java.io.Closeable.close.

if an I/O error occurs

getDocSummaryInformationback to summary
public DocumentSummaryInformation getDocSummaryInformation()

Overrides default org.apache.poi.extractor.POIOLE2TextExtractor.getDocSummaryInformation.

Would return the document information metadata for the document, if we supported it

Returns:DocumentSummaryInformation

Doc from org.apache.poi.extractor.POIOLE2TextExtractor.getDocSummaryInformation.

The Document Summary Information or null if it could not be read for this document.

Annotations
@Override
getDocumentback to summary
public POIDocument getDocument()

Implements org.apache.poi.extractor.POIOLE2TextExtractor.getDocument.

Doc from org.apache.poi.extractor.POIOLE2TextExtractor.getDocument.

Return the underlying POIDocument

Returns:POIDocument

the underlying POIDocument

Annotations
@Override
getFilesystemback to summary
public Closeable getFilesystem()

Implements org.apache.poi.extractor.POITextExtractor.getFilesystem.

Returns:Closeable

Doc from org.apache.poi.extractor.POITextExtractor.getFilesystem.

The underlying resources/filesystem

Annotations
@Override
getRootback to summary
public DirectoryEntry getRoot()

Overrides default org.apache.poi.extractor.POIOLE2TextExtractor.getRoot.

Doc from org.apache.poi.extractor.POIOLE2TextExtractor.getRoot.

Return the underlying DirectoryEntry of this document.

Returns:DirectoryEntry

the DirectoryEntry that is associated with the POIDocument of this extractor.

Annotations
@Override
getSummaryInformationback to summary
public SummaryInformation getSummaryInformation()

Overrides default org.apache.poi.extractor.POIOLE2TextExtractor.getSummaryInformation.

Would return the summary information metadata for the document, if we supported it

Returns:SummaryInformation

Doc from org.apache.poi.extractor.POIOLE2TextExtractor.getSummaryInformation.

The Summary information for the document or null if it could not be read for this document.

Annotations
@Override
getTextback to summary
public String getText()

Implements org.apache.poi.extractor.POITextExtractor.getText, org.apache.poi.ss.extractor.ExcelExtractor.getText.

Retreives the text contents of the file

Returns:String

Doc from org.apache.poi.ss.extractor.ExcelExtractor.getText.

the text contents of the file

isCloseFilesystemback to summary
public boolean isCloseFilesystem()

Implements org.apache.poi.extractor.POITextExtractor.isCloseFilesystem.

Returns:boolean

Doc from org.apache.poi.extractor.POITextExtractor.isCloseFilesystem.

true, if resources/filesystem should be closed on close()

Annotations
@Override
setCloseFilesystemback to summary
public void setCloseFilesystem(boolean doCloseFilesystem)

Implements org.apache.poi.extractor.POITextExtractor.setCloseFilesystem.

Parameters
doCloseFilesystem:boolean

Doc from org.apache.poi.extractor.POITextExtractor.setCloseFilesystem.

true (default), if underlying resources/filesystem should be closed on close()

Annotations
@Override
setFormulasNotResultsback to summary
public void setFormulasNotResults(boolean formulasNotResults)

Implements org.apache.poi.ss.extractor.ExcelExtractor.setFormulasNotResults.

Should we return the formula itself, and not the result it produces? Default is false

Parameters
formulasNotResults:boolean

Doc from org.apache.poi.ss.extractor.ExcelExtractor.setFormulasNotResults.

true if the formula itself is returned

setIncludeCellCommentsback to summary
public void setIncludeCellComments(boolean includeComments)

Implements org.apache.poi.ss.extractor.ExcelExtractor.setIncludeCellComments.

Would control the inclusion of cell comments from the document, if we supported it

Parameters
includeComments:boolean

Doc from org.apache.poi.ss.extractor.ExcelExtractor.setIncludeCellComments.

true if cell comments should be included

setIncludeHeadersFootersback to summary
public void setIncludeHeadersFooters(boolean includeHeadersFooters)

Implements org.apache.poi.ss.extractor.ExcelExtractor.setIncludeHeadersFooters.

Would control the inclusion of headers and footers from the document, if we supported it

Parameters
includeHeadersFooters:boolean

Doc from org.apache.poi.ss.extractor.ExcelExtractor.setIncludeHeadersFooters.

true if headers and footers should be included

setIncludeSheetNamesback to summary
public void setIncludeSheetNames(boolean includeSheetNames)

Implements org.apache.poi.ss.extractor.ExcelExtractor.setIncludeSheetNames.

Should sheet names be included? Default is true

Parameters
includeSheetNames:boolean

Doc from org.apache.poi.ss.extractor.ExcelExtractor.setIncludeSheetNames.

true if the sheet names should be included

triggerExtractionback to summary
private EventBasedExcelExtractor.TextListener triggerExtraction() throws IOException
org.apache.poi.hssf.extractor back to summary

private Class EventBasedExcelExtractor.TextListener

extends Object
implements HSSFListener
Class Inheritance
  • java.lang.Object
  • org.apache.poi.hssf.extractor.EventBasedExcelExtractor.TextListener
All Implemented Interfaces
org.apache.poi.hssf.eventusermodel.HSSFListener

Field Summary

Modifier and TypeField and Description
pack-priv FormatTrackingHSSFListener
pack-priv final StringBuilder
private int
private boolean
private int
private final List<String>
private int
private SSTRecord

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
processRecord(Record
the record to be processed
record
)

Implements org.apache.poi.hssf.eventusermodel.HSSFListener.processRecord.

process an HSSF Record.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_ftback to summary
pack-priv FormatTrackingHSSFListener _ft
_textback to summary
pack-priv final StringBuilder _text
nextRowback to summary
private int nextRow
outputNextStringValueback to summary
private boolean outputNextStringValue
rowNumback to summary
private int rowNum
sheetNamesback to summary
private final List<String> sheetNames
sheetNumback to summary
private int sheetNum
sstRecordback to summary
private SSTRecord sstRecord

Constructor Detail

TextListenerback to summary
public TextListener()

Method Detail

processRecordback to summary
public void processRecord(Record record)

Implements org.apache.poi.hssf.eventusermodel.HSSFListener.processRecord.

Doc from org.apache.poi.hssf.eventusermodel.HSSFListener.processRecord.

process an HSSF Record. Called when a record occurs in an HSSF file.

Parameters
record:Record

the record to be processed