Class XSSFReader
java.lang.Object
org.apache.poi.xssf.eventusermodel.XSSFReader
- Direct Known Subclasses:
XSSFBReader
This class makes it easy to get at individual parts
of an OOXML .xlsx file, suitable for low memory sax
parsing or similar.
It makes up the core part of the EventUserModel support
for XSSF.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classIterator over sheet data.static classstatic final class -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionXSSFReader(OPCPackage pkg) Creates a new XSSFReader, for the given packageXSSFReader(OPCPackage pkg, boolean allowStrictOoxmlFiles) Creates a new XSSFReader, for the given package -
Method Summary
Modifier and TypeMethodDescriptionReturns an InputStream to read the contents of the shared strings table.Opens up the Shared Strings Table, parses it, and returns a handy object for working with shared strings.Returns an InputStream to read the contents of the specified Sheet.static PackagePartgetSheetCommentsPart(PackagePart sheetPart, boolean allowStrictOoxmlFiles) Returns the comments part associated with a sheet.static List<PackagePart>getSheetDrawingParts(PackagePart sheetPart, boolean allowStrictOoxmlFiles) Returns the drawing parts associated with a sheet.Returns an Iterator which will let you get at all the different Sheets in turn.getSheetPart(String relId) Returns the package part for the specified Sheet.Returns an Iterator which will let you get at all the different Sheets in turn.Returns an InputStream to read the contents of the styles table.Opens up the Styles Table, parses it, and returns a handy object for working with cell stylesReturns an InputStream to read the contents of the themes table.Returns an InputStream to read the contents of the main Workbook, which contains key overall data for the file, including sheet definitions.voidsetUseReadOnlySharedStringsTable(boolean useReadOnlySharedStringsTable) boolean
-
Field Details
-
pkg
-
workbookPart
-
-
Constructor Details
-
XSSFReader
Creates a new XSSFReader, for the given package- Throws:
OpenXML4JException- if the package format is invalidIOException- if there is an I/O issue reading the data
-
XSSFReader
public XSSFReader(OPCPackage pkg, boolean allowStrictOoxmlFiles) throws IOException, OpenXML4JException Creates a new XSSFReader, for the given package- Parameters:
pkg- anOPCPackagerepresenting a spreasheet fileallowStrictOoxmlFiles- whether to try to handle Strict OOXML format files- Throws:
OpenXML4JException- if the package format is invalidIOException- if there is an I/O issue reading the data
-
-
Method Details
-
getStylesTable
Opens up the Styles Table, parses it, and returns a handy object for working with cell styles- Returns:
StylesTable- Throws:
InvalidFormatException- if the styles data format is invalidIOException- if there is an I/O issue reading the data
-
getStylesData
Returns an InputStream to read the contents of the styles table.- Returns:
- input stream
- Throws:
InvalidFormatException- if the styles data format is invalidIOException- if there is an I/O issue reading the data
-
getThemesData
Returns an InputStream to read the contents of the themes table.- Returns:
- input stream
- Throws:
InvalidFormatException- if the themes data format is invalidIOException- if there is an I/O issue reading the data
-
getWorkbookData
Returns an InputStream to read the contents of the main Workbook, which contains key overall data for the file, including sheet definitions.- Returns:
- input stream
- Throws:
InvalidFormatException- if the sheet data format is invalidIOException- if there is an I/O issue reading the data
-
getSheet
Returns an InputStream to read the contents of the specified Sheet.- Parameters:
relId- The relationId of the sheet, from a r:id on the workbook- Throws:
InvalidFormatException- if the sheet data format is invalidIOException- if there is an I/O issue reading the data
-
getSheetPart
Returns the package part for the specified Sheet.- Parameters:
relId- The relationId of the sheet, from a r:id on the workbook- Returns:
- the package part holding the sheet data
- Throws:
InvalidFormatException- if the sheet data format is invalidIllegalArgumentException- if there is no sheet with this relationId- Since:
- 6.0.0
-
getSheetCommentsPart
public static PackagePart getSheetCommentsPart(PackagePart sheetPart, boolean allowStrictOoxmlFiles) throws InvalidFormatException Returns the comments part associated with a sheet.- Parameters:
sheetPart- the package part holding the sheet dataallowStrictOoxmlFiles- whether to also look for the Strict OOXML comments relationship. Note that the returned part is then in Strict OOXML format andCommentsTablecannot parse it directly.- Returns:
- the comments part, or null if the sheet has no comments or the part is missing
- Throws:
InvalidFormatException- if the relationship target is not a valid part name- Since:
- 6.0.0
-
getSheetDrawingParts
public static List<PackagePart> getSheetDrawingParts(PackagePart sheetPart, boolean allowStrictOoxmlFiles) throws InvalidFormatException Returns the drawing parts associated with a sheet. Missing parts are skipped.- Parameters:
sheetPart- the package part holding the sheet dataallowStrictOoxmlFiles- whether to also look for the Strict OOXML drawing relationship. Note that the returned parts are then in Strict OOXML format andXSSFDrawingcannot parse them directly.- Returns:
- the drawing parts, never null
- Throws:
InvalidFormatException- if a relationship target is not a valid part name- Since:
- 6.0.0
-
getSheetsData
Returns an Iterator which will let you get at all the different Sheets in turn. Each sheet's InputStream is only opened when fetched from the Iterator. It's up to you to close the InputStreams when done with each one.- Throws:
InvalidFormatException- if the sheet data format is invalidIOException- if there is an I/O issue reading the data- See Also:
-
getSheetIterator
Returns an Iterator which will let you get at all the different Sheets in turn. Each sheet's InputStream is only opened when fetched from the Iterator. It's up to you to close the InputStreams when done with each one.- Throws:
InvalidFormatException- if the sheet data format is invalidIOException- if there is an I/O issue reading the data- Since:
- 5.4.0