How do i set/change the file name of the excel export action for a table ?
The action generated a standard Excel file name but i could not find where the file name is set.
How do i set/change the file name of the excel export action for a table ?
The action generated a standard Excel file name but i could not find where the file name is set.
Hello, David.
To set the name of the excel file you need to replace the standard excel action with your custom realisation and override the export method. For example:
@Inject
private Table<Customer> customerTable;
@Override
public void init(Map<String, Object> params) {
customerTable.addAction(new ExcelAction(customerTable) {
@Override
protected void export(ExcelExporter.ExportMode exportMode) {
ExcelExporter exporter = new ExcelExporter();
exporter.exportTable(table, table.getNotCollapsedColumns(), false, display, null, "custom_file_name", exportMode);
}
});
}
Regards,
Gleb.
Thank you.
Hi,
Why not being able to set the name from the studio, or by calling a function action.setFileName(fileName) ?
It would be very useful!
Thank you!