Class Packer


  • public class Packer
    extends Object
    Class representing packer to compile XLSX files
    Author:
    Raphael Stoeckli
    • Constructor Detail

      • Packer

        public Packer​(LowLevel reference)
        Default constructor with parameter
        Parameters:
        reference - Reference to the low level instance
    • Method Detail

      • addPart

        public void addPart​(String name,
                            String contentType,
                            Document document)
                     throws IOException
        Adds a Part to the file
        Parameters:
        name - Filename with relative path
        contentType - URL with information about the content type (MSXML).
        This information is used in the main content type file
        document - XML document to add
        Throws:
        IOException - Thrown if the document could not be converted to a byte array
      • addPart

        public void addPart​(String name,
                            String contentType,
                            Document document,
                            boolean includeInContentType)
                     throws IOException
        Adds a Part to the file
        Parameters:
        name - Filename with relative path
        contentType - URL with information about the content type (MSXML).
        This information is used in the main content type file
        document - XML document to add
        includeInContentType - If true, the content type will be added in the main content type file, otherwise not
        Throws:
        IOException - Thrown if the document could not be converted to a byte array
      • createRelationship

        public Packer.Relationship createRelationship​(String path)
        Creates a relationship. This will be used to generate a .rels file in the compilation (MSXML)
        Parameters:
        path - relative path and filename to rels file (e.g. _rels/.rels)
        Returns:
        Returns the object reference to add relationship entries
      • pack

        public void pack​(OutputStream stream)
                  throws IOException
        Method to pack the data into a XLSX file. This is the actual compiling and writing method (to a OutputStream)
        Parameters:
        stream - OutputStream to save the data into
        Throws:
        IOException - Thrown in case of a error while packing or writing