PDA

View Full Version : Change downloaded XLS file name using exporterbutton



Hardik013
6 Apr 2015, 9:14 PM
Hello ,

I want to download an Excel file of my grid. I am using an exporterbutton and its working fine , but i want to change my downloaded file name , Every-time the file name remains same (default file name : download.xls)

Here it is my code ,

tbar: [{

xtype: 'exporterbutton',
format: "excel",
fileName: 'Exporter',
title: 'User Report',
text : 'Export to XLS',
// downloadName : "download"
},

tristan.lee
14 Apr 2015, 10:14 AM
Hi,

exporterbutton is a user extension we do not support. However, looking at the Ext.ux.Exporter.Button class, there is a downloadName config option that may change the name of the file to what you're looking for. Best of luck.

Tristan

Hardik013
15 Apr 2015, 5:20 AM
Hello , I have tried with this downloadName , but still it is not working, and after downloading xls file , it gives an error for opening a file ,

The error is , "The file format and extension of 'download.xls' don't match.The file could be corrupted or unsafe.Unless you trust on source ,don't open it , do you want to open it anyway..?"

tristan.lee
15 Apr 2015, 5:59 AM
Hi,

That's a common security notice when dealing with files like this. The content of the file is likely an HTML table which is not a true Excel file like the xls extension indicates, even though Excel is able to render it properly. Therefore, the application provides you with the notice informing you of that.

Unless the extension provides a way of exporting as CSV or you come up with a server-side solution that returns the content in true XLS format, the application will generate this message.

Thanks,
Tristan