Class StreamingReader.Builder

    • Constructor Detail

      • Builder

        public Builder()
    • 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. Use StreamingWorkbook.getSheetAt(int) instead.
        Which sheet to open. There can only be one sheet open for a single instance of StreamingReader. 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. Use StreamingWorkbook.getSheet(String) instead.
        Which sheet to open. There can only be one sheet open for a single instance of StreamingReader. 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 a ReadException is thrown on read.

        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 if 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.

        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 given 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).
        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 given File and returns a new instance of Workbook.
        Parameters:
        file - file to read in
        Returns:
        built streaming reader instance
        Throws:
        OpenException - if there is an issue opening the file
        ReadException - if there is an issue reading the file
      • read

        public StreamingReader read​(InputStream is)
        Deprecated.
        This method will be removed in a future release. Use open(InputStream) instead
        Reads a given InputStream and returns a new instance of StreamingReader. 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).
        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. Use open(File) instead
        Reads a given File and returns a new instance of StreamingReader.
        Parameters:
        f - file to read in
        Returns:
        built streaming reader instance
        Throws:
        OpenException - if there is an issue opening the file
        ReadException - if there is an issue reading the file