Set file name to excel

Hi,

When i download the table data using excel export action, a default name is used i.e. table name. But I want to provide a file name.

How do I set a file name at runtime, when the excel export action is used to download.

Thanks in advance

Hi!
You can extend ExcelExportAction and override method getFileName(DataGrid<Object> dataGrid).

Hi,

ExcelExportAction doesn’t have a method named getFileName.

Oh, sorry!

You can extend ExcelExportAction and ExcelExporter
In ExcelExportAction override

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) {
        super.setApplicationContext(applicationContext);
        withExporter(ExcelExporter.class);
    }

In ExcelExporter override

    protected String getFileName(Table<Object> table) {
        String fileName = this.fileName;
        if (fileName == null) {
            return getMetaClassName(((ContainerTableItems) table.getItems()).getEntityMetaClass());
        }
        return fileName;
    }

when I try there is a problem

NoUniqueBeanDefinitionException: No qualifying bean of type ‘io.jmix.uiexport.exporter.excel.ExcelExporter’ available: expected single matching bean but found 2: CustomExporter,ui_ExcelExporter

Hi @nunziaandrulli, I also encountered this problem, have you found a solution?