|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.poi.ss.usermodel.WorkbookFactory
public class WorkbookFactory
Factory for creating the appropriate kind of Workbook
(be it HSSFWorkbook
or XSSFWorkbook
),
by auto-detecting from the supplied input.
Constructor Summary | |
---|---|
WorkbookFactory()
|
Method Summary | |
---|---|
static Workbook |
create(java.io.File file)
Creates the appropriate HSSFWorkbook / XSSFWorkbook from the given File, which must exist and be readable. |
static Workbook |
create(java.io.File file,
java.lang.String password)
Creates the appropriate HSSFWorkbook / XSSFWorkbook from the given File, which must exist and be readable, and may be password protected |
static Workbook |
create(java.io.File file,
java.lang.String password,
boolean readOnly)
Creates the appropriate HSSFWorkbook / XSSFWorkbook from the given File, which must exist and be readable, and may be password protected |
static Workbook |
create(java.io.InputStream inp)
Creates the appropriate HSSFWorkbook / XSSFWorkbook from the given InputStream. |
static Workbook |
create(java.io.InputStream inp,
java.lang.String password)
Creates the appropriate HSSFWorkbook / XSSFWorkbook from the given InputStream, which may be password protected. |
static Workbook |
create(NPOIFSFileSystem fs)
Creates a HSSFWorkbook from the given NPOIFSFileSystem |
static Workbook |
create(OPCPackage pkg)
Creates a XSSFWorkbook from the given OOXML Package |
static Workbook |
create(POIFSFileSystem fs)
Creates a HSSFWorkbook from the given POIFSFileSystem |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public WorkbookFactory()
Method Detail |
---|
public static Workbook create(POIFSFileSystem fs) throws java.io.IOException
Note that in order to properly release resources the Workbook should be closed after use.
java.io.IOException
public static Workbook create(NPOIFSFileSystem fs) throws java.io.IOException
Note that in order to properly release resources the Workbook should be closed after use.
java.io.IOException
public static Workbook create(OPCPackage pkg) throws java.io.IOException
Note that in order to properly release resources the Workbook should be closed after use.
pkg
- The OPCPackage
opened for reading data.
java.io.IOException
- if an error occurs while reading the datapublic static Workbook create(java.io.InputStream inp) throws java.io.IOException, InvalidFormatException, EncryptedDocumentException
Your input stream MUST either support mark/reset, or
be wrapped as a PushbackInputStream
! Note that
using an InputStream
has a higher memory footprint
than using a File
.
Note that in order to properly release resources the
Workbook should be closed after use. Note also that loading
from an InputStream requires more memory than loading
from a File, so prefer create(File)
where possible.
inp
- The InputStream
to read data from.
java.io.IOException
- if an error occurs while reading the data
InvalidFormatException
- if the contents of the file cannot be parsed into a Workbook
EncryptedDocumentException
- If the workbook given is password protectedpublic static Workbook create(java.io.InputStream inp, java.lang.String password) throws java.io.IOException, InvalidFormatException, EncryptedDocumentException
Your input stream MUST either support mark/reset, or
be wrapped as a PushbackInputStream
! Note that
using an InputStream
has a higher memory footprint
than using a File
.
Note that in order to properly release resources the
Workbook should be closed after use. Note also that loading
from an InputStream requires more memory than loading
from a File, so prefer create(File)
where possible.
inp
- The InputStream
to read data from.password
- The password that should be used or null if no password is necessary.
java.io.IOException
- if an error occurs while reading the data
InvalidFormatException
- if the contents of the file cannot be parsed into a Workbook
EncryptedDocumentException
- If the wrong password is given for a protected file
EmptyFileException
- If an empty stream is givenpublic static Workbook create(java.io.File file) throws java.io.IOException, InvalidFormatException, EncryptedDocumentException
Note that in order to properly release resources the Workbook should be closed after use.
file
- The file to read data from.
java.io.IOException
- if an error occurs while reading the data
InvalidFormatException
- if the contents of the file cannot be parsed into a Workbook
EncryptedDocumentException
- If the workbook given is password protectedpublic static Workbook create(java.io.File file, java.lang.String password) throws java.io.IOException, InvalidFormatException, EncryptedDocumentException
Note that in order to properly release resources the Workbook should be closed after use.
file
- The file to read data from.password
- The password that should be used or null if no password is necessary.
java.io.IOException
- if an error occurs while reading the data
InvalidFormatException
- if the contents of the file cannot be parsed into a Workbook
EncryptedDocumentException
- If the wrong password is given for a protected file
EmptyFileException
- If an empty stream is givenpublic static Workbook create(java.io.File file, java.lang.String password, boolean readOnly) throws java.io.IOException, InvalidFormatException, EncryptedDocumentException
Note that in order to properly release resources the Workbook should be closed after use.
file
- The file to read data from.password
- The password that should be used or null if no password is necessary.readOnly
- If the Workbook should be opened in read-only mode to avoid writing back
changes when the document is closed.
java.io.IOException
- if an error occurs while reading the data
InvalidFormatException
- if the contents of the file cannot be parsed into a Workbook
EncryptedDocumentException
- If the wrong password is given for a protected file
EmptyFileException
- If an empty stream is given
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |