Export"
From Documentation
m |
|||
Line 11: | Line 11: | ||
PivotExportContext context = Exports.getExportContext(pivot, false, null); | PivotExportContext context = Exports.getExportContext(pivot, false, null); | ||
Exports.exportExcel(out, "xls", context, null); // writes Pivottable information to the output stream | Exports.exportExcel(out, "xls", context, null); // writes Pivottable information to the output stream | ||
− | Filedownload.save(out.toByteArray(), " | + | Filedownload.save(out.toByteArray(), "application/vnd.ms-excel", "pivot.xls"); // file download |
try { | try { | ||
out.close(); | out.close(); | ||
Line 23: | Line 23: | ||
| | ||
+ | |||
==Export to CSV== | ==Export to CSV== | ||
Revision as of 04:59, 13 March 2012
You can export the computed result of Pivottable to other formats.
Export to Microsoft Excel
Given a Pivottable instance, you can dump the current result in .xls format to an OutputStream. The exported Excel file contains a sheet that reflects the computed result you see on browser windows, without paging. For example,
ByteArrayOutputStream out = new ByteArrayOutputStream();
PivotExportContext context = Exports.getExportContext(pivot, false, null);
Exports.exportExcel(out, "xls", context, null); // writes Pivottable information to the output stream
Filedownload.save(out.toByteArray(), "application/vnd.ms-excel", "pivot.xls"); // file download
try {
out.close();
} catch (IOException e) {}
PivotExportContext
PivotExportContext is an intermediate result for exporting Pivottable to a table/sheet data structure. You can construct it from a Pivottable, or from a PivotModel and a PivotRenderer (so you don't need a component instance).
Export to CSV
Version History
Version | Date | Content |
---|---|---|