"addPrintable" for DataGrid?

I required some features of the DataGrid so I exchanged a GroupTable with a DataGrid, so far everything is working besides the Excel printout action. I use the ComponentRenderer for the columns and in the GroupTable I had the method addPrintable to define the values for the Excel export. Is there a similar mechanism in the datagrid?

All I can see in the export, is the string representations of the components:


Unfortunately, there is no similar functionality in the DataGrid. For now, the only way is to extend ExcelExporter class and override the createDataGridRow() method:

public class MyExcelExporter extends ExcelExporter {

    protected void createDataGridRow(DataGrid dataGrid, List<DataGrid.Column> columns, int startColumn, int rowNumber, Object itemId) {
        super.createDataGridRow(dataGrid, columns, startColumn, rowNumber, itemId);

And use:

private DataGrid<Project> dataGrid;
private ExportDisplay exportDisplay;

private MyExcelExporter myExcelExporter = new MyExcelExporter();

public void onDataGridExcel(Action.ActionPerformedEvent event) {
    myExcelExporter.exportDataGrid(dataGrid, exportDisplay);
1 Like