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

kaushalmbkaushalmb Posts: 7Questions: 1Answers: 1

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.

Answers

  • allanallan Posts: 63,540Questions: 1Answers: 10,476 Site admin
    Answer ✓

    is that the case for you in this example? I get the attached image in IE11.

    Allan

  • kaushalmbkaushalmb Posts: 7Questions: 1Answers: 1

    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.

  • allanallan Posts: 63,540Questions: 1Answers: 10,476 Site admin
    edited September 2016 Answer ✓

    It sounds like your IE11 doesn't support the APIs required to create an exported file.

    This is the check it runs:

        available: function () {
            return window.FileReader !== undefined && _jsZip() !== undefined && ! _isSafari() && _serialiser;
        },
    

    That should pass in IE11 since it does for me. Can you give me a link to your page please?

    Allan

  • kaushalmbkaushalmb Posts: 7Questions: 1Answers: 1
    edited September 2016

    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 :neutral:

    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.

  • allanallan Posts: 63,540Questions: 1Answers: 10,476 Site admin

    Are you able to debug which part of the available method from excelHtml5 is returning false in IE11 for you? Just to check - you aren't using it in quirks more or some compatibility mode?

    Allan

  • kaushalmbkaushalmb Posts: 7Questions: 1Answers: 1

    I am not able to reach "available" when using 'excelHtml5'.

  • allanallan Posts: 63,540Questions: 1Answers: 10,476 Site admin

    Even on the example page I linked to above? Does that page work for you in IE11?

    Allan

  • F12MagicF12Magic Posts: 109Questions: 0Answers: 28
    Answer ✓

    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.

  • allanallan Posts: 63,540Questions: 1Answers: 10,476 Site admin

    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

  • kaushalmbkaushalmb Posts: 7Questions: 1Answers: 1
    edited October 2016

    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 :(

  • kaushalmbkaushalmb Posts: 7Questions: 1Answers: 1

    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.

  • kaushalmbkaushalmb Posts: 7Questions: 1Answers: 1
    Answer ✓

    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 :neutral:

    Now it is working as expected.

    Thank you @allan and @F12Magic for support.

  • allanallan Posts: 63,540Questions: 1Answers: 10,476 Site admin

    Thanks for the update. Good to hear you've got it working now.

    Allan

This discussion has been closed.