Class OdfSpreadsheetDocument

  • All Implemented Interfaces:
    Closeable, AutoCloseable

    public class OdfSpreadsheetDocument
    extends OdfDocument
    This class represents an empty ODF spreadsheet document.
    • Method Detail

      • newSpreadsheetDocument

        public static OdfSpreadsheetDocument newSpreadsheetDocument()
                                                             throws Exception
        Creates an empty spreadsheet document.
        Returns:
        ODF spreadsheet document based on a default template*
        Throws:
        Exception - - if the document could not be created
      • newSpreadsheetTemplateDocument

        public static OdfSpreadsheetDocument newSpreadsheetTemplateDocument()
                                                                     throws Exception
        Creates an empty spreadsheet template.
        Returns:
        ODF spreadsheet template based on a default
        Throws:
        Exception - - if the template could not be created
      • loadDocument

        public static OdfSpreadsheetDocument loadDocument​(InputStream inputStream)
                                                   throws Exception
        Creates an OdfSpreadsheetDocument from the OpenDocument provided by a resource Stream.

        Since an InputStream does not provide the arbitrary (non sequentiell) read access needed by OdfSpreadsheetDocument, the InputStream is cached. This usually takes more time compared to the other createInternalDocument methods. An advantage of caching is that there are no problems overwriting an input file.

        If the resource stream is not a ODF spreadsheet document, ClassCastException might be thrown.

        Parameters:
        inputStream - - the InputStream of the ODF spreadsheet document.
        Returns:
        the spreadsheet document created from the given InputStream
        Throws:
        Exception - - if the document could not be created.
      • loadDocument

        public static OdfSpreadsheetDocument loadDocument​(String documentPath)
                                                   throws Exception
        Loads an OdfSpreadsheetDocument from the provided path.

        OdfSpreadsheetDocument relies on the file being available for read access over the whole lifecycle of OdfSpreadsheetDocument.

        If the resource stream is not a ODF spreadsheet document, ClassCastException might be thrown.

        Parameters:
        documentPath - - the path from where the document can be loaded
        Returns:
        the spreadsheet document from the given path or NULL if the media type is not supported by ODFDOM.
        Throws:
        Exception - - if the document could not be created.
      • loadDocument

        public static OdfSpreadsheetDocument loadDocument​(File file)
                                                   throws Exception
        Creates an OdfSpreadsheetDocument from the OpenDocument provided by a File.

        OdfSpreadsheetDocument relies on the file being available for read access over the whole lifecycle of OdfSpreadsheetDocument.

        If the resource stream is not a ODF spreadsheet document, ClassCastException might be thrown.

        Parameters:
        file - - a file representing the ODF spreadsheet document.
        Returns:
        the spreadsheet document created from the given File
        Throws:
        Exception - - if the document could not be created.
      • changeMode

        public void changeMode​(OdfSpreadsheetDocument.OdfMediaType mediaType)
        Changes the document to the given mediatype. This method can only be used to convert a document to a related mediatype, e.g. template.
        Parameters:
        mediaType - the related ODF mimetype
      • getSpreadsheetTables

        public List<OdfTable> getSpreadsheetTables()
        Return a list of table features in this document. For general ODF documents it searches for them recursively through the document. For ODF documents, there is a getOdsTableList
        Returns:
        a list of table features in this document.