Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.poi
Class POIXMLDocument

    java.lang.Object
      org.apache.poi.POIXMLDocumentPart
          org.apache.poi.POIXMLDocument

All Implemented Interfaces:
  java.io.Closeable

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.POIXMLDocumentPart
`POIXMLDocumentPart.RelationPart`

Field Summary
`static java.lang.String` | `DOCUMENT_CREATOR`
`static java.lang.String` | `OLE_OBJECT_REL_TYPE`
`static java.lang.String` | `PACK_OBJECT_REL_TYPE`

Constructor Summary
`protected` | `POIXMLDocument(OPCPackage pkg)`
`protected` | `POIXMLDocument(OPCPackage pkg, java.lang.String coreDocumentRel)`

Method Summary
`void` | `close()` Closes the underlying `OPCPackage` from which this document was read, if there is one
`abstract java.util.List<PackagePart>` | `getAllEmbedds()` Get the document's embedded files.
`protected PackagePart` | `getCorePart()`
`OPCPackage` | `getPackage()` Get the assigned OPCPackage
`POIXMLProperties` | `getProperties()` Get the document properties.
`protected PackagePart[]` | `getRelatedByType(java.lang.String contentType)` Retrieves all the PackageParts which are defined as relationships of the base document with the specified content type.
`protected void` | `load(POIXMLFactory factory)`
`static OPCPackage` | `openPackage(java.lang.String path)` Wrapper to open a package, which works around shortcomings in java's this() constructor calls
`void` | `write(java.io.OutputStream stream)` Write out this document to an Outputstream.

Methods inherited from class org.apache.poi.POIXMLDocumentPart
`_invokeOnDocumentRead, addRelation, commit, createRelationship, createRelationship, createRelationship, getNextPartNumber, getPackagePart, getParent, getRelationById, getRelationId, getRelationParts, getRelations, getTargetPart, onDocumentCreate, onDocumentRead, onDocumentRemove, onSave, prepareForCommit, read, rebase, removeRelation, removeRelation, toString`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

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

Constructor Detail

### POIXMLDocument

    protected POIXMLDocument(OPCPackage pkg)

### POIXMLDocument

    protected POIXMLDocument(OPCPackage pkg,
                             java.lang.String coreDocumentRel)

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

### getCorePart

    protected PackagePart getCorePart()

### getRelatedByType

    protected PackagePart[] getRelatedByType(java.lang.String contentType)
                                      throws InvalidFormatException

  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:
    `XSSFRelation`, `XSLFRelation`, `XWPFRelation`, `XDGFRelation`

### 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

    public abstract java.util.List<PackagePart> getAllEmbedds()
                                                       throws OpenXML4JException

  Get the document's embedded files.

  Returns:
    the document's embedded files
  Throws:
    `OpenXML4JException` - if the embedded parts can't be determined

### load

    protected final void load(POIXMLFactory factory)
                       throws java.io.IOException

  Throws:
    `java.io.IOException`

### close

    public void close()
               throws java.io.IOException

  Closes the underlying `OPCPackage` from which this document was read, if there is one

  Once this has been called, no further operations, updates or reads should be performed on the document.

  Specified by:
    `close` in interface `java.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 a `File` rather than an `InputStream`, you must write out to a different file, overwriting via an OutputStream isn't possible. If `stream` is a `FileOutputStream` on a networked drive or has a high cost/latency associated with each written byte, consider wrapping the OutputStream in a `BufferedOutputStream` 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.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright 2017 The Apache Software Foundation or its licensors, as applicable.