public static class StreamingReader.Builder
extends java.lang.Object
Constructor and Description |
---|
Builder() |
Modifier and Type | Method and Description |
---|---|
boolean |
adjustLegacyComments() |
boolean |
avoidTempFiles() |
StreamingReader.Builder |
bufferSize(int bufferSize)
The number of bytes to read into memory from the input
resource.
|
boolean |
encryptCommentsTempFile() |
boolean |
encryptSstTempFile() |
boolean |
fullFormatRichText()
Whether to parse the full formatting data for rich text shared strings and comments.
|
int |
getBufferSize() |
CommentsImplementationType |
getCommentsImplementationType() |
java.lang.String |
getPassword() |
int |
getRowCacheSize() |
SharedStringsImplementationType |
getSharedStringsImplementationType() |
org.apache.poi.ss.usermodel.Workbook |
open(java.io.File file)
Reads a given
File and returns a new instance
of Workbook . |
org.apache.poi.ss.usermodel.Workbook |
open(java.io.InputStream is)
Reads a given
InputStream and returns a new
instance of Workbook . |
StreamingReader.Builder |
password(java.lang.String password)
For password protected files, specify password to open file.
|
boolean |
readComments() |
boolean |
readCoreProperties() |
boolean |
readHyperlinks() |
boolean |
readShapes() |
boolean |
readSharedFormulas() |
boolean |
readStyles() |
StreamingReader.Builder |
rowCacheSize(int rowCacheSize)
The number of rows to keep in memory at any given point.
|
StreamingReader.Builder |
setAdjustLegacyComments(boolean adjustLegacyComments)
Enables adjustments to comments to remove boiler-plate text (related to threaded comments).
|
StreamingReader.Builder |
setAvoidTempFiles(boolean avoidTempFiles)
Enables a mode where the code tries to avoid creating temp files.
|
StreamingReader.Builder |
setCommentsImplementationType(CommentsImplementationType commentsImplementationType)
Set the type of Comments Table to use.
|
StreamingReader.Builder |
setEncryptCommentsTempFile(boolean encryptCommentsTempFile)
Enables use of encryption in the Comments temp file.
|
StreamingReader.Builder |
setEncryptSstTempFile(boolean encryptSstTempFile)
Enables use of encryption in Shared Strings Table temp file.
|
StreamingReader.Builder |
setFullFormatRichText(boolean fullFormatRichText)
Whether to parse the full formatting data for rich text shared strings and comments.
|
StreamingReader.Builder |
setReadComments(boolean readComments)
Enables the reading of the comments.
|
StreamingReader.Builder |
setReadCoreProperties(boolean readCoreProperties)
Enables the reading of the core document properties.
|
StreamingReader.Builder |
setReadHyperlinks(boolean readHyperlinks)
Enables the reading of hyperlink data associated with sheets).
|
StreamingReader.Builder |
setReadShapes(boolean readShapes)
Enables the reading of shape data.
|
StreamingReader.Builder |
setReadSharedFormulas(boolean readSharedFormulas)
Enables the reading of shared formulas.
|
StreamingReader.Builder |
setReadStyles(boolean readStyles)
Enables/disables the reading of styles data.
|
StreamingReader.Builder |
setSharedStringsImplementationType(SharedStringsImplementationType sharedStringsImplementationType)
Set the type of Shared Strings Table to use.
|
StreamingReader.Builder |
setUseCommentsTempFile(boolean useCommentsTempFile)
Deprecated.
|
StreamingReader.Builder |
setUseSstReadOnly(boolean useSstReadOnly)
|
StreamingReader.Builder |
setUseSstTempFile(boolean useSstTempFile)
|
boolean |
useCommentsTempFile()
Deprecated.
|
boolean |
useSstReadOnly()
Deprecated.
use #getSharedStringsImplementationType()
|
boolean |
useSstTempFile()
Deprecated.
use #getSharedStringsImplementationType()
|
public int getRowCacheSize()
public int getBufferSize()
public java.lang.String getPassword()
public boolean avoidTempFiles()
public SharedStringsImplementationType getSharedStringsImplementationType()
POI_READ_ONLY
).setSharedStringsImplementationType(SharedStringsImplementationType)
public CommentsImplementationType getCommentsImplementationType()
POI_DEFAULT
).setCommentsImplementationType(CommentsImplementationType)
@Deprecated public boolean useSstTempFile()
@Deprecated public boolean useSstReadOnly()
ReadOnlySharedStringsTable
instead
of SharedStringsTable
. If you use setUseSstTempFile(boolean)
and set to `true`, then this setting is ignored.useSstTempFile()
public boolean encryptSstTempFile()
useSstTempFile()
is true.public boolean adjustLegacyComments()
public boolean readComments()
@Deprecated public boolean useCommentsTempFile()
getCommentsImplementationType()
public boolean encryptCommentsTempFile()
useCommentsTempFile()
is true.public boolean readCoreProperties()
public boolean readHyperlinks()
public boolean readShapes()
public boolean readSharedFormulas()
public boolean readStyles()
public boolean fullFormatRichText()
useSstTempFile()
,
useCommentsTempFile()
public StreamingReader.Builder rowCacheSize(int rowCacheSize)
Defaults to 10
rowCacheSize
- number of rowsBuilder
public StreamingReader.Builder bufferSize(int bufferSize)
Defaults to 1024
bufferSize
- buffer size in bytesBuilder
public StreamingReader.Builder password(java.lang.String password)
ReadException
is thrown on
read
.
NULL indicates that no password should be used, this is the default value.
password
- to use when opening fileBuilder
public StreamingReader.Builder setAvoidTempFiles(boolean avoidTempFiles)
#setUseSstTempFile
and #setUseCommentsTempFile
.
By default, temp files are used to avoid holding onto too much data in memory.
avoidTempFiles
- whether to avoid using temp files when reading from input streamsBuilder
public StreamingReader.Builder setSharedStringsImplementationType(SharedStringsImplementationType sharedStringsImplementationType)
POI_READ_ONLY
.
If you enable this feature, you may also want to enable fullFormatRichText
.
sharedStringsImplementationType
- type of Shared Strings Table to use (must not be null)Builder
java.lang.NullPointerException
- if null is passed as a paramgetSharedStringsImplementationType()
public StreamingReader.Builder setCommentsImplementationType(CommentsImplementationType commentsImplementationType)
POI_DEFAULT
.
If you enable this feature, you may also want to enable fullFormatRichText
.
commentsImplementationType
- type of Comments Table to use (must not be null)Builder
java.lang.NullPointerException
- if null is passed as a paramgetCommentsImplementationType()
@Deprecated public StreamingReader.Builder setUseSstTempFile(boolean useSstTempFile)
By default, the entire SST *will* be loaded into memory. However, enabling this option at all will have some noticeable performance degradation as you are trading memory for disk space.
If you enable this feature, you may also want to enable fullFormatRichText
.
useSstTempFile
- whether to use a temp file to store the Shared Strings Table dataBuilder
setEncryptSstTempFile(boolean)
,
setFullFormatRichText(boolean)
,
setUseSstReadOnly(boolean)
@Deprecated public StreamingReader.Builder setUseSstReadOnly(boolean useSstReadOnly)
ReadOnlySharedStringsTable
is a simpler implementation than
the default SharedStringsTable
and uses less memory - but may not support formatted
text as well.useSstReadOnly
- Whether to use ReadOnlySharedStringsTable
instead
of SharedStringsTable
.Builder
setUseSstTempFile(boolean)
public StreamingReader.Builder setEncryptSstTempFile(boolean encryptSstTempFile)
setUseSstTempFile
is set to true.
By default, the temp file is not encrypted. However, enabling this option could slow down the processing of Shared Strings data.
encryptSstTempFile
- whether to encrypt the temp file used to store the Shared Strings Table dataBuilder
setUseSstTempFile(boolean)
@Deprecated public StreamingReader.Builder setUseCommentsTempFile(boolean useCommentsTempFile)
setCommentsImplementationType(CommentsImplementationType)
By default, all the Comments data *will* be loaded into memory. However, enabling this option at all will have some noticeable performance degradation as you are trading memory for disk space.
If you enable this feature, you also want to enable fullFormatRichText
.
useCommentsTempFile
- whether to use a temp file to store the Comments dataBuilder
setReadComments(boolean)
,
setEncryptCommentsTempFile(boolean)
,
setFullFormatRichText(boolean)
public StreamingReader.Builder setEncryptCommentsTempFile(boolean encryptCommentsTempFile)
setUseCommentsTempFile
is set to true.
By default, the temp file is not encrypted. However, enabling this option could slow down the processing of Comments data.
encryptCommentsTempFile
- whether to encrypt the temp file used to store the Comments dataBuilder
setReadComments(boolean)
,
setUseCommentsTempFile(boolean)
public StreamingReader.Builder setReadComments(boolean readComments)
readComments
- whether to read the comments associated with sheets and cellsBuilder
public StreamingReader.Builder setAdjustLegacyComments(boolean adjustLegacyComments)
adjustLegacyComments
- whether to adjust legacy comments to remove boilerplate commentsBuilder
public StreamingReader.Builder setReadCoreProperties(boolean readCoreProperties)
readCoreProperties
- whether to read the core document propertiesBuilder
public StreamingReader.Builder setReadHyperlinks(boolean readHyperlinks)
readHyperlinks
- whether to read hyperlink data (associated with sheets)Builder
public StreamingReader.Builder setReadShapes(boolean readShapes)
readShapes
- whether to read shapes (associated with pictures that appear in sheets)Builder
public StreamingReader.Builder setReadSharedFormulas(boolean readSharedFormulas)
readSharedFormulas
- whether to read shared formulasBuilder
public StreamingReader.Builder setReadStyles(boolean readStyles)
The style data is very useful for formatting numbers in particular because the raw numbers in the Excel file are in double precision format and may not match exactly what you see in the Excel cell.
With date and timestamp data, the raw data is also numeric and without the style data, the reader
will treat the data as numeric. If you already know if certain cells hold date or timestamp data,
the the getLocalDateTimeCellValue
and getDateCellValue
methods will work
even if you have disabled the reading of style data.
readStyles
- Whether to read the styles (associated with cells)Builder
public StreamingReader.Builder setFullFormatRichText(boolean fullFormatRichText)
fullFormatRichText
- Whether to parse the full formatting data for rich text shared strings and comments.Builder
setUseSstTempFile(boolean)
,
setUseCommentsTempFile(boolean)
public org.apache.poi.ss.usermodel.Workbook open(java.io.InputStream is)
InputStream
and returns a new
instance of Workbook
. Due to Apache POI
limitations, a temporary file must be written in order
to create a streaming iterator. This process will use
the same buffer size as specified in bufferSize(int)
.is
- input stream to read inWorkbook
that can be read fromReadException
- if there is an issue reading the streampublic org.apache.poi.ss.usermodel.Workbook open(java.io.File file)
File
and returns a new instance
of Workbook
.file
- file to read inOpenException
- if there is an issue opening the fileReadException
- if there is an issue reading the file