Package org.apache.poi.ooxml
Class POIXMLDocument
- java.lang.Object
-
- org.apache.poi.ooxml.POIXMLDocumentPart
-
- org.apache.poi.ooxml.POIXMLDocument
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
- Direct Known Subclasses:
XMLSlideShow
,XmlVisioDocument
,XSLFSlideShow
,XSSFWorkbook
,XWPFDocument
public abstract class POIXMLDocument extends POIXMLDocumentPart implements java.io.Closeable
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 Modifier and Type Field Description static java.lang.String
DOCUMENT_CREATOR
static java.lang.String
OLE_OBJECT_REL_TYPE
static java.lang.String
PACK_OBJECT_REL_TYPE
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
close()
Closes the underlyingOPCPackage
from which this document was read, if there is oneabstract java.util.List<PackagePart>
getAllEmbeddedParts()
Get the document's embedded files.java.util.List<PackagePart>
getAllEmbedds()
Deprecated.usegetAllEmbeddedParts
insteadOPCPackage
getPackage()
Get the assigned OPCPackagePOIXMLProperties
getProperties()
Get the document properties.static OPCPackage
openPackage(java.lang.String path)
Wrapper to open a package, which works around shortcomings in java's this() constructor callsvoid
write(java.io.OutputStream stream)
Write out this document to an Outputstream.-
Methods inherited from class org.apache.poi.ooxml.POIXMLDocumentPart
_invokeOnDocumentRead, addRelation, createRelationship, createRelationship, createRelationship, getPackagePart, getParent, getRelationById, getRelationId, getRelationPartById, getRelationParts, getRelations, isCommited, setCommited, toString
-
-
-
-
Field Detail
-
DOCUMENT_CREATOR
public static final java.lang.String DOCUMENT_CREATOR
- See Also:
- Constant Field Values
-
OLE_OBJECT_REL_TYPE
public static final java.lang.String OLE_OBJECT_REL_TYPE
- See Also:
- Constant Field Values
-
PACK_OBJECT_REL_TYPE
public static final java.lang.String PACK_OBJECT_REL_TYPE
- See Also:
- Constant Field Values
-
-
Method Detail
-
openPackage
public static OPCPackage openPackage(java.lang.String path) throws java.io.IOException
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:
java.io.IOException
- if there was a problem opening the document
-
getPackage
public OPCPackage getPackage()
Get the assigned OPCPackage- Returns:
- the assigned OPCPackage
-
getProperties
public POIXMLProperties 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 java.util.List<PackagePart> getAllEmbedds() throws OpenXML4JException
Deprecated.usegetAllEmbeddedParts
insteadGet the document's embedded files.- Returns:
- the document's embedded files
- Throws:
OpenXML4JException
- if the embedded parts can't be determined
-
getAllEmbeddedParts
public abstract java.util.List<PackagePart> getAllEmbeddedParts() throws OpenXML4JException
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
-
close
public void close() throws java.io.IOException
Closes the underlyingOPCPackage
from 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:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Throws:
java.io.IOException
- for writable packages, if an IO exception occur during the saving process.
-
write
public final void write(java.io.OutputStream stream) throws java.io.IOException
Write out this document to an Outputstream. Note - if the Document was opened from aFile
rather than anInputStream
, you must write out to a different file, overwriting via an OutputStream isn't possible. Ifstream
is aFileOutputStream
on a networked drive or has a high cost/latency associated with each written byte, consider wrapping the OutputStream in aBufferedOutputStream
to improve write performance.- Parameters:
stream
- - the java OutputStream you wish to write the file to- Throws:
java.io.IOException
- if anything can't be written.
-
-