I need to add customized title for excel file exported from Datatable.
Tried this from a stackoverflow answer but it applies to whole sheet.
$("#datatable").DataTable({
dom: "lBfrtip",
buttons: [
{
extend: "excelHtml5",
title: "Audit Trail Report",
messageTop: `From ${this.start_date} To ${this.end_date}`,
customize: function (xlsx) {
var sheet = xlsx.xl["styles.xml"];
var tagName = sheet.getElementsByTagName("sz");
for (let i = 0; i < tagName.length; i++) {
tagName[i].setAttribute("val", "22");
}
},
},
{
extend: "pdf",
title: "Audit Trail Report",
messageTop: `From ${this.start_date} To ${this.end_date}`,
},
],
searching: false,
})