Package org.apache.poi.ooxml
Class POIXMLDocument
java.lang.Object
org.apache.poi.ooxml.POIXMLDocumentPart
org.apache.poi.ooxml.POIXMLDocument
- All Implemented Interfaces:
Closeable,AutoCloseable
- Direct Known Subclasses:
XMLSlideShow,XmlVisioDocument,XSLFSlideShow,XSSFWorkbook,XWPFDocument
This holds the common functionality for all POI OOXML Document classes.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.poi.ooxml.POIXMLDocumentPart
POIXMLDocumentPart.RelationPart -
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedPOIXMLDocument(OPCPackage pkg) protectedPOIXMLDocument(OPCPackage pkg, String coreDocumentRel) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the underlyingOPCPackagefrom which this document was read, if there is oneabstract List<PackagePart>Get the document's embedded files.Deprecated.protected PackagePartGet the assigned OPCPackageGet the document properties.protected PackagePart[]getRelatedByType(String contentType) Retrieves all the PackageParts which are defined as relationships of the base document with the specified content type.protected final voidload(POIXMLFactory factory) static OPCPackageopenPackage(String path) Wrapper to open a package, which works around shortcomings in java's this() constructor callsfinal voidwrite(OutputStream stream) Write out this document to an Outputstream.Methods inherited from class org.apache.poi.ooxml.POIXMLDocumentPart
_invokeOnDocumentRead, addRelation, commit, createRelationship, createRelationship, createRelationship, getNextPartNumber, getPackagePart, getParent, getRelationById, getRelationId, getRelationPartById, getRelationParts, getRelations, getTargetPart, isCommited, onDocumentCreate, onDocumentRead, onDocumentRemove, onSave, prepareForCommit, read, rebase, removeRelation, removeRelation, removeRelation, setCommited, toString
-
Field Details
-
DOCUMENT_CREATOR
- See Also:
-
OLE_OBJECT_REL_TYPE
- See Also:
-
PACK_OBJECT_REL_TYPE
- See Also:
-
-
Constructor Details
-
POIXMLDocument
-
POIXMLDocument
-
-
Method Details
-
openPackage
Wrapper to open a package, which works around shortcomings in java's this() constructor calls- Parameters:
path- the path to the document- Returns:
- the new OPCPackage
- Throws:
IOException- if there was a problem opening the document
-
getPackage
Get the assigned OPCPackage- Returns:
- the assigned OPCPackage
-
getCorePart
-
getRelatedByType
Retrieves all the PackageParts which are defined as relationships of the base document with the specified content type.- Parameters:
contentType- the content type- Returns:
- all the base document PackageParts which match the content type
- Throws:
InvalidFormatException- when the relationships or the parts contain errors- See Also:
-
getProperties
Get the document properties. This gives you access to the core ooxml properties, and the extended ooxml properties.- Returns:
- the document properties
-
getAllEmbedds
@Deprecated @Removal(version="4.2") public List<PackagePart> getAllEmbedds() throws OpenXML4JExceptionDeprecated.usegetAllEmbeddedPartsinsteadGet the document's embedded files.- Returns:
- the document's embedded files
- Throws:
OpenXML4JException- if the embedded parts can't be determined
-
getAllEmbeddedParts
Get the document's embedded files.- Returns:
- the document's embedded files
- Throws:
OpenXML4JException- if the embedded parts can't be determined- Since:
- POI 4.0.0
-
load
- Throws:
IOException
-
close
Closes the underlyingOPCPackagefrom which this document was read, if there is oneOnce this has been called, no further operations, updates or reads should be performed on the document.
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException- for writable packages, if an IO exception occur during the saving process.
-
write
Write out this document to an Outputstream. Note - if the Document was opened from aFilerather than anInputStream, you must write out to a different file, overwriting via an OutputStream isn't possible. Ifstreamis aFileOutputStreamon a networked drive or has a high cost/latency associated with each written byte, consider wrapping the OutputStream in aBufferedOutputStreamto improve write performance.- Parameters:
stream- - the java OutputStream you wish to write the file to- Throws:
IOException- if anything can't be written.
-
getAllEmbeddedPartsinstead