I'm going straight to the point. I am trying to export an excel file using datatbable ... however I want to add a new line before exporting the file. I am really new to datatable, so please bear with me.
this is what i have done so far.
in part customize:function()I want to add new lines before the heading ... the heading is actually a parameter for generating the table.
Example:
NAME:SampleName
Date From: 2016-05-01
Date To: 2016-05-31
var handleDataTableButtons = function() {
if ($("#datatable-responsive-returns-report").length) {
$("#datatable-responsive-returns-report").DataTable({
"bSort": false,
scrollX: true,
iDisplayLength: 50,
dom: "Bfrtip",
buttons: [
{
extend:"copy",
className:"btn-sm"
},
{
extend:"excel",
className:"btn-sm",
text:"Export to Excel",
customize:function(xlsx){
var sheet = xlsx.xl.worksheets['sheet1.xml'];
console.log(sheet);
/add new row
},
filename: ($(".universal_name option:selected").text() == "" ? $(".hid_universal_name").val() : $(".universal_name option:selected").text()) + " - " + $(".universal_title").val()+"("+$(".date_from").val()+" to "+$(".date_to").val()+")"
}
],
});
}
};
TableManageButtons = function() {
"use strict";
return {
init: function() {
handleDataTableButtons();
}
};
}();
thanks in advance...
source
share