I have customized the excel in datatable with number format using jQuery, it's working fine but when I added the background color, number format is removed, cannot add a multiple style at a time.
This is my js code
$('#summary-table').DataTable({
"ajax": {
"url": "/summary-report",
},
"columns": [
{"data": "start_balance"},
{"data": "total_redeems"},
],
dom: 'Blfrtip',
"footerCallback": function (tfoot, data, start, end, display) {
var api = this.api();
var intVal = function(i) {
return typeof i === 'string' ?
i.replace(/[\$,]/g, '') * 1 :
typeof i === 'number' ?
i : 0;
};
var sp = api.column(2).data().reduce(function (a, b) {
return intVal(a) + intVal(b);
}, 0)
var sTotal = new Number(sp).toLocaleString("LKR");
$(api.column(2).footer()).html(" " +sTotal);
},
buttons: [
{
extend: "excel",
className: "btn excel",
footer:true,
filename: function () {
return "MovementSummary_Report";
},
title: 'System',
customize : function (xlsx) {
var sheet = xlsx.xl.worksheets['sheet1.xml'];
var numberFormat = ['B'];
for ( i=0; i < numberFormat.length; i++ ) {
$('row:eq(-1) c[r^='+numberFormat[i]+']', sheet).attr( 's', '63' );
$('row:eq(-1) c[r^='+numberFormat[i]+']', sheet).attr( 's', '17' );
}
},
messageTop: function () {
return (
"Movement Summary | " +
MEMBER_SUMMARY_REPORT_SELECTED_DATE_RANGE
);
},
},
],
});