Datatable Export to Excel button opening file dialog instead of direct saving on IE11
Datatable Export to Excel button opening file dialog instead of direct saving on IE11
I am trying to implement "Export To Excel" function for Datatable using following code:
'dom': 'Bfrtip',
'buttons': [{
extend: 'excel',
text: 'Export To Excel',
filename: exportFileName,
exportOptions: { columns: ':visible' }
}]
This code works fine except one thing. It is opening file save dialog instead of downloading with new IE save file dialog (bottom of browser) it is opening classic save file dialog.
Please help me to resolve this.
Thanks in advance.
This question has accepted answers - jump to:
Answers
is that the case for you in this example? I get the attached image in IE11.
Allan
Hi Allan,
Thank you for your response and suggested solution.
Unfortunately, when I am using 'excelhtml5' instead of 'excel' (which might rendering flash button) I am unable to get Excel button on UI.
We are using
1. Buttons for DataTables 1.10.12 js
2. DataTables 1.2.2 js
Please suggest.
Thanks.
It sounds like your IE11 doesn't support the APIs required to create an exported file.
This is the check it runs:
That should pass in IE11 since it does for me. Can you give me a link to your page please?
Allan
Thanks for quick response.
I had tried to breakpoint at excel: function (dt, conf) in Buttons for DataTables 1.10.12 js. after setting **extend: 'excelHtml5' **.
But it is not coming to breakpoint. But if I change it to **extend: 'excel' ** then go to condition for excelFlash.
Thus bit consfused
I tried to force execute return 'excelHtml5'; while debugging....but it is not returning any excel button.
available: function () is returning false for 'excel' and not coming for 'excelHtml5' as breakpoint not hitting.
About link to page, this is intranet application which is not available to share.
Thanks.
P.S.: image attached showcasing some other option I had tried.
Are you able to debug which part of the
available
method fromexcelHtml5
is returning false in IE11 for you? Just to check - you aren't using it in quirks more or some compatibility mode?Allan
I am not able to reach "available" when using 'excelHtml5'.
Even on the example page I linked to above? Does that page work for you in IE11?
Allan
Could be wrong, but sounds like wrong loading order of the javascript files. Are you loading jszip.js before any other extension file like buttons.js ?
I had the same issue last week when making a template on codepen.
With the latest version of Buttons it should actually be possible to load JSZip after the Buttons files. You typically wouldn't but it should be possible.
Allan
I have found following link;
https://datatables.net/reference/button/excelHtml5
in Example section: There is comment:
DataTables initialisation: Use the excel button type to automatically select between the Flash and HTML button options.:
$('#myTable').DataTable( {
buttons: [
'excel'
]
} );
I am using this code only but it is default selecting Flash button over html5, How can I sent default as html5 button. So above code can work as HTML5.
P.S. I have tried to use 'excelHtml5' explicitly but at runtime not button rendered
Following is order of js files;
jquery_dataTables.js
dataTables.buttons.js
buttons.flash.js
buttons.html5.js
dataTables.fixedColumns.min.js
dataTables.bootstrap.js
dataTables.scroller.js
How to configure to force 'excel' to select HTML5 button instead of Flash button.
UPDATE:
There was very silly mistake (I should realize when Allan replied with available function code). I had missed to include jszip.min.js file
Now it is working as expected.
Thank you @allan and @F12Magic for support.
Thanks for the update. Good to hear you've got it working now.
Allan