org.zkoss.pivot.util
Class Exports

java.lang.Object
  extended by org.zkoss.pivot.util.Exports

public class Exports
extends java.lang.Object

Utility class for PivotTable Exporter

Author:
vincentjian, Neil Lee

Nested Class Summary
static class Exports.PivotExportCell
          The cell unit for exporting to sheet-based format.
static interface Exports.PivotExportContext
          A context object containing information required for exporting to other files
 
Field Summary
static java.lang.String DEFAULT_FORMAT
          Default file format for exporting to excel.
 
Constructor Summary
Exports()
           
 
Method Summary
static void exportCSV(java.io.OutputStream out, Exports.PivotExportContext context)
          Export Pivottable to CSV format, with comma as separator
static void exportCSV(java.io.OutputStream out, Exports.PivotExportContext context, java.lang.String separator)
          Export Pivottable to CSV format.
static void exportExcel(java.io.OutputStream out, Exports.PivotExportContext context)
          Export Pivottable to default Excel 2007 format
static void exportExcel(java.io.OutputStream out, java.lang.String fileFormat, Exports.PivotExportContext context)
          Export Pivottable to excel format.
static void exportExcel(java.io.OutputStream out, java.lang.String fileFormat, Exports.PivotExportContext context, CellStyleConfigurator styleConfig)
          Export Pivottable to excel format.
static void exportExcel(java.io.OutputStream out, org.zkoss.poi.ss.usermodel.Workbook book, Exports.PivotExportContext context)
          Export Pivottable to excel format.
static void exportExcel(java.io.OutputStream out, org.zkoss.poi.ss.usermodel.Workbook book, Exports.PivotExportContext context, CellStyleConfigurator styleConfig)
          Export Pivottable to excel format.
static Exports.PivotExportContext getExportContext(PivotModel model, PivotRenderer renderer, java.lang.String dataFieldOrient, boolean open, java.lang.String[] titles)
          Return a context for exporting Pivottable information
static Exports.PivotExportContext getExportContext(PivotModel model, PivotRenderer renderer, java.lang.String dataFieldOrient, boolean open, java.lang.String[] titles, boolean useRendererForDataCells)
           
static Exports.PivotExportContext getExportContext(Pivottable table, boolean open, java.lang.String[] titles)
          Return a context for exporting Pivottable information
static Exports.PivotExportContext getExportContext(Pivottable table, boolean open, java.lang.String[] titles, boolean useRendererForDataCells)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_FORMAT

public static final java.lang.String DEFAULT_FORMAT
Default file format for exporting to excel. Use library property org.zkoss.pivot.export.format to specify different default.

Constructor Detail

Exports

public Exports()
Method Detail

exportExcel

public static void exportExcel(java.io.OutputStream out,
                               Exports.PivotExportContext context)
                        throws java.io.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:
java.io.IOException
Since:
2.2.0

exportExcel

public static void exportExcel(java.io.OutputStream out,
                               java.lang.String fileFormat,
                               Exports.PivotExportContext context)
                        throws java.io.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:
java.io.IOException

exportExcel

public static void exportExcel(java.io.OutputStream out,
                               org.zkoss.poi.ss.usermodel.Workbook book,
                               Exports.PivotExportContext context)
                        throws java.io.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
Workbook - the workbook either HSSFWorkbook or XSSFWorkbook, if null will use HSSFWorkbook.
context - the export context created from Pivottable or model
Throws:
java.io.IOException
Since:
2.2.0

exportExcel

public static void exportExcel(java.io.OutputStream out,
                               java.lang.String fileFormat,
                               Exports.PivotExportContext context,
                               CellStyleConfigurator styleConfig)
                        throws java.io.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:
java.io.IOException

exportExcel

public static void exportExcel(java.io.OutputStream out,
                               org.zkoss.poi.ss.usermodel.Workbook book,
                               Exports.PivotExportContext context,
                               CellStyleConfigurator styleConfig)
                        throws java.io.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
Workbook - 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:
java.io.IOException
Since:
2.2.0

exportCSV

public static void exportCSV(java.io.OutputStream out,
                             Exports.PivotExportContext context)
                      throws java.io.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:
java.io.IOException

exportCSV

public static void exportCSV(java.io.OutputStream out,
                             Exports.PivotExportContext context,
                             java.lang.String separator)
                      throws java.io.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:
java.io.IOException

getExportContext

public static Exports.PivotExportContext getExportContext(Pivottable table,
                                                          boolean open,
                                                          java.lang.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 Exports.PivotExportContext getExportContext(Pivottable table,
                                                          boolean open,
                                                          java.lang.String[] titles,
                                                          boolean useRendererForDataCells)

getExportContext

public static Exports.PivotExportContext getExportContext(PivotModel model,
                                                          PivotRenderer renderer,
                                                          java.lang.String dataFieldOrient,
                                                          boolean open,
                                                          java.lang.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.

getExportContext

public static Exports.PivotExportContext getExportContext(PivotModel model,
                                                          PivotRenderer renderer,
                                                          java.lang.String dataFieldOrient,
                                                          boolean open,
                                                          java.lang.String[] titles,
                                                          boolean useRendererForDataCells)


Copyright © 2015. All Rights Reserved.