Exporting to XLS
The PivotTableExporter
bean provides an API for downloading a pivot table with aggregated data in the XLS (Excel) format.
To utilize the PivotTableExporter
, you need to create an instance of the bean within your view controller. You will need to pass the following parameters:
-
PivotTable
: A reference to thepivotTable
component from which you want to export data. -
PivotTableExcelExporter
: An instance of thePivotTableExcelExporter
class, responsible for handling the Excel export process.
Here’s an example of how to use the PivotTableExporter
in your view controller:
@Subscribe
protected void onInit(InitEvent event) {
PivotTableExcelExporter pivotTableExcelExporter = getApplicationContext()
.getBean(PivotTableExcelExporter.class);
pivotTableExport = getApplicationContext()
.getBean(PivotTableExporter.class, pivotTable, pivotTableExcelExporter);
}
The export functionality currently supports the following renderer types: TABLE , TABLE_BAR_CHART , HEATMAP , COL_HEATMAP , and ROW_HEATMAP . It’s important to note that cell colors are not exported.
|
The exportTableToXls()
method provides a way to download the table data as an XLS (Excel) file. This is typically triggered by a button click in your UI. For example:
@Subscribe(id = "exportButton", subject = "clickListener")
public void onExportButtonClick(final ClickEvent<JmixButton> event) {
pivotTableExport.exportTableToXls();
}
The XLS format has a limitation of 65536 rows. If the Pivot Table contains more than 65536 rows, the content will be truncated at the last row, and you will see a warning message indicating this. |
Was this page helpful?
Thank you for your feedback