4.2. Exporting PivotTable Data
PivotTableExtension is the extension of the PivotTable component that provides API for downloading the table with aggregated data in the XLS format.
An instance of the extension should be created in the screen controller using the class constructor (i.e., not the UiComponents bean), for example:
@Inject
private PivotTable pivotTable;
private PivotTableExtension extension;
@Subscribe
private void onInit(InitEvent event) {
extension = new WebPivotTableExtension(pivotTable)
}
|
Tip
|
The extension works only for the following renderers types: |
The exportTableToXls() method allows you to download the table data as an XLS file, for example, on a button click:
extension.exportTableToXls();
By default, the downloaded file name matches the localized caption of the entity in the PivotTable data container. The file name can be defined using the setFileName() method:
extension.setFileName("Orders of " + new Date());
|
Tip
|
The XLS format implies the limitation for 65536 table rows. If |
Additionally, the PivotTableExtension provides two more ways to get the PivotTable data:
-
the JSON representation:
extension.getPivotDataJSON(); -
the serialized object of
PivotDataclass:extension.getPivotData();