Limitations

  • When TreeTable or TreeDataGrid is exported no padding will be added to the column with hierarchy property.

  • When GroupTable is exported, no grouping will be added to the Excel file.

  • Exporting of entities with composite primary key is not supported.

Exporting Tables with Generated Columns

If you use custom generated columns in the Table, GroupTable, or TreeTable component, their content is not exported by default.

To define values for columns, use the addColumnValueProvider() method of the ExportAction class.

In the example below, the columnGenerator is used for the isEmail column. To define values to be exported via ExcelExportAction, add a function to get value from the column:

@Named("customersTable.excel")
protected ExcelExportAction customersTableExcel;

@Subscribe
protected void onInit(InitEvent event) {
    customersTableExcel.addColumnValueProvider("isEmail", context -> {
        Customer customer = context.getEntity();
        return customer.getEmail() != null;
    });
}

@Install(to = "customersTable.isEmail", subject = "columnGenerator")
protected Component customersTableIsEmailColumnGenerator(Customer customer) {
    CheckBox isEmail = uiComponents.create(CheckBox.class);
    isEmail.setValue(customer.getEmail() != null);
    return isEmail;
}