Package com.github.pjfanning.xlsx
Class StreamingReader.Builder
- java.lang.Object
-
- com.github.pjfanning.xlsx.StreamingReader.Builder
-
- Enclosing class:
- StreamingReader
public static class StreamingReader.Builder extends Object
-
-
Constructor Summary
Constructors Constructor Description Builder()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description StreamingReader.Builder
bufferSize(int bufferSize)
The number of bytes to read into memory from the input resource.boolean
encryptSstTempFile()
int
getBufferSize()
String
getPassword()
int
getRowCacheSize()
int
getSheetIndex()
Deprecated.This method will be removed in a future release.String
getSheetName()
Deprecated.This method will be removed in a future release.org.apache.poi.ss.usermodel.Workbook
open(File file)
Reads a givenFile
and returns a new instance ofWorkbook
.org.apache.poi.ss.usermodel.Workbook
open(InputStream is)
Reads a givenInputStream
and returns a new instance ofWorkbook
.StreamingReader.Builder
password(String password)
For password protected files specify password to open file.StreamingReader
read(File f)
Deprecated.This method will be removed in a future release.StreamingReader
read(InputStream is)
Deprecated.This method will be removed in a future release.StreamingReader.Builder
rowCacheSize(int rowCacheSize)
The number of rows to keep in memory at any given point.StreamingReader.Builder
setEncryptSstTempFile(boolean encryptSstTempFile)
Enables use of encryption in Shared Strings Table temp file.StreamingReader.Builder
setUseSstTempFile(boolean useSstTempFile)
Enables use of Shared Strings Table temp file.StreamingReader.Builder
sheetIndex(int sheetIndex)
Deprecated.This method will be removed in a future release.StreamingReader.Builder
sheetName(String sheetName)
Deprecated.This method will be removed in a future release.boolean
useSstTempFile()
-
-
-
Method Detail
-
getRowCacheSize
public int getRowCacheSize()
-
getBufferSize
public int getBufferSize()
-
getSheetIndex
public int getSheetIndex()
Deprecated.This method will be removed in a future release.- Returns:
- The sheet index
-
getSheetName
public String getSheetName()
Deprecated.This method will be removed in a future release.- Returns:
- The sheet name
-
getPassword
public String getPassword()
- Returns:
- The password to use to unlock this workbook
-
useSstTempFile
public boolean useSstTempFile()
- Returns:
- Whether to use a temp file for the Shared Strings data. If false, no temp file will be used and the entire table will be loaded into memory.
-
encryptSstTempFile
public boolean encryptSstTempFile()
- Returns:
- Whether to encrypt the temp file for the Shared Strings data. Only applies if
useSstTempFile()
is true.
-
rowCacheSize
public StreamingReader.Builder rowCacheSize(int rowCacheSize)
The number of rows to keep in memory at any given point.Defaults to 10
- Parameters:
rowCacheSize
- number of rows- Returns:
- reference to current
Builder
-
bufferSize
public StreamingReader.Builder bufferSize(int bufferSize)
The number of bytes to read into memory from the input resource.Defaults to 1024
- Parameters:
bufferSize
- buffer size in bytes- Returns:
- reference to current
Builder
-
sheetIndex
public StreamingReader.Builder sheetIndex(int sheetIndex)
Deprecated.This method will be removed in a future release. UseStreamingWorkbook.getSheetAt(int)
instead.Which sheet to open. There can only be one sheet open for a single instance ofStreamingReader
. If more sheets need to be read, a new instance must be created.Defaults to 0
- Parameters:
sheetIndex
- index of sheet- Returns:
- reference to current
Builder
-
sheetName
public StreamingReader.Builder sheetName(String sheetName)
Deprecated.This method will be removed in a future release. UseStreamingWorkbook.getSheet(String)
instead.Which sheet to open. There can only be one sheet open for a single instance ofStreamingReader
. If more sheets need to be read, a new instance must be created.- Parameters:
sheetName
- name of sheet- Returns:
- reference to current
Builder
-
password
public StreamingReader.Builder password(String password)
For password protected files specify password to open file. If the password is incorrect aReadException
is thrown onread
.NULL indicates that no password should be used, this is the default value.
- Parameters:
password
- to use when opening file- Returns:
- reference to current
Builder
-
setUseSstTempFile
public StreamingReader.Builder setUseSstTempFile(boolean useSstTempFile)
Enables use of Shared Strings Table temp file. This option exists to accommodate extremely large workbooks with millions of unique strings. Normally the SST is entirely loaded into memory, but with large workbooks with high cardinality (i.e., very few duplicate values) the SST may not fit entirely into memory.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.
- Parameters:
useSstTempFile
- whether to use a temp file to store the Shared Strings Table data- Returns:
- reference to current
Builder
-
setEncryptSstTempFile
public StreamingReader.Builder setEncryptSstTempFile(boolean encryptSstTempFile)
Enables use of encryption in Shared Strings Table temp file. This only applies ifsetUseSstTempFile
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.
- Parameters:
encryptSstTempFile
- whether to encrypt the temp file used to store the Shared Strings Table data- Returns:
- reference to current
Builder
-
open
public org.apache.poi.ss.usermodel.Workbook open(InputStream is)
Reads a givenInputStream
and returns a new instance ofWorkbook
. 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 inbufferSize(int)
.- Parameters:
is
- input stream to read in- Returns:
- A
Workbook
that can be read from - Throws:
ReadException
- if there is an issue reading the stream
-
open
public org.apache.poi.ss.usermodel.Workbook open(File file)
Reads a givenFile
and returns a new instance ofWorkbook
.- Parameters:
file
- file to read in- Returns:
- built streaming reader instance
- Throws:
OpenException
- if there is an issue opening the fileReadException
- if there is an issue reading the file
-
read
public StreamingReader read(InputStream is)
Deprecated.This method will be removed in a future release. Useopen(InputStream)
insteadReads a givenInputStream
and returns a new instance ofStreamingReader
. 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 inbufferSize(int)
.- Parameters:
is
- input stream to read in- Returns:
- built streaming reader instance
- Throws:
ReadException
- if there is an issue reading the stream
-
read
public StreamingReader read(File f)
Deprecated.This method will be removed in a future release. Useopen(File)
insteadReads a givenFile
and returns a new instance ofStreamingReader
.- Parameters:
f
- file to read in- Returns:
- built streaming reader instance
- Throws:
OpenException
- if there is an issue opening the fileReadException
- if there is an issue reading the file
-
-