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

public Class ExcelExtractor

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.File, .IOException, .InputStream, .PrintStream, java.nio.file.Files, java.util.Locale, org.apache.poi.extractor.POIOLE2TextExtractor, org.apache.poi.hssf.usermodel.HSSFCell, .HSSFCellStyle, .HSSFComment, .HSSFDataFormatter, .HSSFRichTextString, .HSSFRow, .HSSFSheet, .HSSFWorkbook, org.apache.poi.poifs.filesystem.DirectoryNode, .POIFSFileSystem, org.apache.poi.ss.formula.eval.ErrorEval, org.apache.poi.ss.usermodel.HeaderFooter, .Row.MissingCellPolicy

A text extractor for Excel files.

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 static class
private static class

Field Summary

Modifier and TypeField and Description
private final HSSFDataFormatter
private boolean
private boolean
private boolean
private boolean
private boolean
private final HSSFWorkbook
private boolean

Constructor Summary

AccessConstructor and Description
public
public
public

Method Summary

Modifier and TypeMethod and Description
public static String
public HSSFWorkbook
getDocument()

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

Return the underlying POIDocument

public HSSFWorkbook
public String
public boolean
public static void
main(String[]
the command line parameters
args
)

Command line extractor.

private static void
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
setIncludeBlankCells(boolean
true if blank cells should be included
includeBlankCells
)

Should blank cells be output?

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

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

Should cell comments be included?

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

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

Should headers and footers be included in the output?

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?

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_formatterback to summary
private final HSSFDataFormatter _formatter
_includeBlankCellsback to summary
private boolean _includeBlankCells
_includeCellCommentsback to summary
private boolean _includeCellComments
_includeHeadersFootersback to summary
private boolean _includeHeadersFooters
_includeSheetNamesback to summary
private boolean _includeSheetNames
_shouldEvaluateFormulasback to summary
private boolean _shouldEvaluateFormulas
_wbback to summary
private final HSSFWorkbook _wb
doCloseFilesystemback to summary
private boolean doCloseFilesystem

Constructor Detail

ExcelExtractorback to summary
public ExcelExtractor(HSSFWorkbook wb)
ExcelExtractorback to summary
public ExcelExtractor(POIFSFileSystem fs) throws IOException
ExcelExtractorback to summary
public ExcelExtractor(DirectoryNode dir) throws IOException

Method Detail

_extractHeaderFooterback to summary
public static String _extractHeaderFooter(HeaderFooter hf)
getDocumentback to summary
public HSSFWorkbook getDocument()

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

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

Return the underlying POIDocument

Returns:HSSFWorkbook

the underlying POIDocument

Annotations
@Override
getFilesystemback to summary
public HSSFWorkbook getFilesystem()

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

Returns:HSSFWorkbook

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

The underlying resources/filesystem

Annotations
@Override
getTextback to summary
public String getText()

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

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

Retrieves the text contents of the file

Returns:String

the text contents of the file

Annotations
@Override
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
mainback to summary
public static void main(String[] args) throws IOException

Command line extractor.

Parameters
args:String[]

the command line parameters

Exceptions
IOException:
if the file can't be read or contains errors
printUsageMessageback to summary
private static void printUsageMessage(PrintStream ps)
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.

Doc from 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

true if the formula itself is returned

Annotations
@Override
setIncludeBlankCellsback to summary
public void setIncludeBlankCells(boolean includeBlankCells)

Should blank cells be output? Default is to only output cells that are present in the file and are non-blank.

Parameters
includeBlankCells:boolean

true if blank cells should be included

setIncludeCellCommentsback to summary
public void setIncludeCellComments(boolean includeCellComments)

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

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

Should cell comments be included? Default is false

Parameters
includeCellComments:boolean

true if cell comments should be included

Annotations
@Override
setIncludeHeadersFootersback to summary
public void setIncludeHeadersFooters(boolean includeHeadersFooters)

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

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

Should headers and footers be included in the output? Default is true

Parameters
includeHeadersFooters:boolean

true if headers and footers should be included

Annotations
@Override
setIncludeSheetNamesback to summary
public void setIncludeSheetNames(boolean includeSheetNames)

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

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

Should sheet names be included? Default is true

Parameters
includeSheetNames:boolean

true if the sheet names should be included

Annotations
@Override
org.apache.poi.hssf.extractor back to summary

private final Class ExcelExtractor.CommandArgs

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final boolean
private final boolean
private final File
private final boolean
private final boolean
private final boolean
private final boolean

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public File
public boolean
private static boolean
parseBoolArg(String[] args, int i)

public boolean
public boolean
public boolean
public boolean
public boolean
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_evaluateFormulasback to summary
private final boolean _evaluateFormulas
_headersFootersback to summary
private final boolean _headersFooters
_inputFileback to summary
private final File _inputFile
_requestHelpback to summary
private final boolean _requestHelp
_showBlankCellsback to summary
private final boolean _showBlankCells
_showCellCommentsback to summary
private final boolean _showCellComments
_showSheetNamesback to summary
private final boolean _showSheetNames

Constructor Detail

CommandArgsback to summary
public CommandArgs(String[] args) throws CommandParseException

Method Detail

getInputFileback to summary
public File getInputFile()
isRequestHelpback to summary
public boolean isRequestHelp()
parseBoolArgback to summary
private static boolean parseBoolArg(String[] args, int i) throws CommandParseException
shouldEvaluateFormulasback to summary
public boolean shouldEvaluateFormulas()
shouldIncludeHeadersFootersback to summary
public boolean shouldIncludeHeadersFooters()
shouldShowBlankCellsback to summary
public boolean shouldShowBlankCells()
shouldShowCellCommentsback to summary
public boolean shouldShowCellComments()
shouldShowSheetNamesback to summary
public boolean shouldShowSheetNames()
org.apache.poi.hssf.extractor back to summary

private final Class ExcelExtractor.CommandParseException

extends Exception
Class Inheritance

Constructor Summary

AccessConstructor and Description
public

Constructor Detail

CommandParseExceptionback to summary
public CommandParseException(String msg)