I have a script which adds an export to Excel button to my datatables:
$(document).ready(function() {
$('#table_id').DataTable( {
dom: 'Brtip',
buttons: [
{
extend: 'excel',
filename: function(){
var today = new Date();
var date = today.getFullYear()+'-'+(today.getMonth()+1)+'-'+today.getDate();
var time = today.getHours() +':'+ today.getMinutes()+':'+today.getSeconds();
var dateTime = date+' '+time;
return 'Query ' + dateTime;
},
customize: function ( xlsx ) {
var sheet = xlsx.xl.worksheets['sheet1.xml'];
$('c[r=A1] t', sheet).text( '{{foo_query}}' );
$('c[r=A2] t', sheet).text( '' );
$('row:first c', sheet).attr( 's', '2' ); // first row is bold
}
}
]
} );
});
This works fine:
However, I am only showing the top 200 hits in the datatable, as the actual dataframe is 35,000+ and takes too long to load.
When I click the Excel button it sends the data that is in the table, but ideally I want it to export the original data which I hold as a global variable called 'dataHold'
Is there any way do do this?