vignesh vignesh - 3 months ago 13
jQuery Question

automatic export to excel using datatables

I am using jQuery datatable

The export to excel can be added by

$('table.data-table').DataTable({
paging: false,
columnDefs: [{
targets: 'no-sort',
orderable: false
}],


But I want to download an excel file automatically when I initiate the
datatable


Is there an option to do that?
Here is a fiddle with export to excel working on click of excel button

I want it to happen automatically

Answer

You could click() the excel button in the initComplete callback :

initComplete: function() {
   $('.buttons-excel').click()
}

forked fiddle (not intentionally) -> https://jsfiddle.net/850z70do/

Comments