Class Exports


  • public class Exports
    extends Object
    Utility class for PivotTable Exporter
    Author:
    vincentjian, Neil Lee
    • Constructor Detail

      • Exports

        public Exports()
    • Method Detail

      • exportExcel

        public static void exportExcel​(OutputStream out,
                                       PivotExportContext context)
                                throws IOException
        Export Pivottable to default Excel 2007 format
        Parameters:
        out - the output stream to write to
        context - the export context created from Pivottable or model
        Throws:
        IOException
        Since:
        2.2.0
      • exportExcel

        public static void exportExcel​(OutputStream out,
                                       String fileFormat,
                                       PivotExportContext context)
                                throws IOException
        Export Pivottable to excel format. Note:
        1. "xlsx" format creates a sheet with native Pivot Table (also contains a sheet with source data)
        2. "xlsx.static" format creates a sheet with Pivottable data.
        3. "xls" format creates a sheet with Pivottable data.
        Parameters:
        out - the output stream to write to
        fileFormat - "xls", "xlsx", or "xlsx.static" supported.
        context - the export context created from Pivottable or model
        Throws:
        IOException
      • exportExcel

        public static void exportExcel​(OutputStream out,
                                       org.zkoss.poi.ss.usermodel.Workbook book,
                                       PivotExportContext context)
                                throws IOException
        Export Pivottable to excel format.

        Note the XSSFWorkbook workbook create sheet with native Pivot Table (also contains a sheet with source data),
        the HSSFWorkbook workbook create sheet with Pivottable data.

        Parameters:
        out - the output stream to write to
        book - the workbook either HSSFWorkbook or XSSFWorkbook, if null will use HSSFWorkbook.
        context - the export context created from Pivottable or model
        Throws:
        IOException
        Since:
        2.2.0
      • exportExcel

        public static void exportExcel​(OutputStream out,
                                       String fileFormat,
                                       PivotExportContext context,
                                       CellStyleConfigurator styleConfig)
                                throws IOException
        Export Pivottable to excel format.
        1. "xlsx" format creates a sheet with native Pivot Table (also contains a sheet with source data)
        2. "xlsx.static" format creates a sheet with Pivottable data.
        3. "xls" format creates a sheet with Pivottable data.
        Parameters:
        out - the output stream to write to
        fileFormat - "xls", "xlsx", or "xlsx.static" supported.
        context - the export context created from Pivottable or model
        styleConfig - configurator for excel cell style
        Throws:
        IOException
      • exportExcel

        public static void exportExcel​(OutputStream out,
                                       org.zkoss.poi.ss.usermodel.Workbook book,
                                       PivotExportContext context,
                                       CellStyleConfigurator styleConfig)
                                throws IOException
        Export Pivottable to excel format.

        Note the XSSFWorkbook workbook create sheet with native Pivot Table (also contains a sheet with source data),
        the HSSFWorkbook workbook create sheet with Pivottable data.

        Parameters:
        out - the output stream to write to
        book - the workbook either HSSFWorkbook or XSSFWorkbook, if null will use HSSFWorkbook.
        context - the export context created from Pivottable or model
        styleConfig - configurator for excel cell style
        Throws:
        IOException
        Since:
        2.2.0
      • exportCSV

        public static void exportCSV​(OutputStream out,
                                     PivotExportContext context)
                              throws IOException
        Export Pivottable to CSV format, with comma as separator
        Parameters:
        out - the output stream to write to
        context - the export context created from Pivottable or model
        Throws:
        IOException
      • exportCSV

        public static void exportCSV​(OutputStream out,
                                     PivotExportContext context,
                                     String separator)
                              throws IOException
        Export Pivottable to CSV format.
        Parameters:
        out - the output stream to write to
        context - the export context created from Pivottable or model
        separator - the separator for marking cell boundary in CSV file
        Throws:
        IOException
      • getExportContext

        public static PivotExportContext getExportContext​(Pivottable table,
                                                          boolean open,
                                                          String[] titles)
        Return a context for exporting Pivottable information
        Parameters:
        table - the Pivottable instance
        open - export as if all the header nodes were open (the model is not affected)
        titles - title text for data, column, row title cells, respectively. i.e. titles[0] will be rendered to the data title cell, titles[1] to the column title cell, and titles[2] to the row title cell.
      • getExportContext

        public static PivotExportContext getExportContext​(PivotModel model,
                                                          PivotRenderer renderer,
                                                          String dataFieldOrient,
                                                          boolean open,
                                                          String[] titles)
        Return a context for exporting Pivottable information
        Parameters:
        model - the PivotModel
        renderer - the PivotRenderer
        dataFieldOrient - to arrange data fields on column or row, if there are multiple data fields. Accepted values are "column" and "row".
        open - export as if all the header nodes were open (the model is not affected)
        titles - title text for data, column, row title cells, respectively. i.e. titles[0] will be rendered to the data title cell, titles[1] to the column title cell, and titles[2] to the row title cell.