JSFiddle - React, Tailwind, and code Playground
HTML
<div class="table_div" style="float: left; width: 99%; overflow-x: auto">
<table id="example" class="display Bil" cellspacing="0" width="100%" style="font-family: Arial;
overflow-x: scroll; width: 1336px; font-size: small; font-weight: normal; border-collapse: collapse;
white-space: nowrap; clear: both;">
<thead id="HEADER">
</thead>
<tbody id="tblempDetails" class="alignfields">
</tbody>
<tfoot id="FOOTER">
</tfoot>
</table>
</div>
JavaScript
table = $('#example').DataTable({
responsive: true,
columnDefs: [
{ responsivePriority: 1, targets: 0 },
{ responsivePriority: 2, targets: -2 }
],
paging: true,
searching: false,
// processing: true,
dom: 'Bfrtip',
buttons: ['colvis', { extend: 'excel', exportOptions: { columns: ':visible' }, title: $("#ctl00_ContentPlaceHolder1_lblPageName").text(),
customize: function (xlsx) {
var sheet = xlsx.xl.worksheets['sheet1.xml'];
var numrows = 7;
debugger;
var mergeCells = $('mergeCells', sheet);
mergeCells[0].appendChild(_createNode(sheet, 'mergeCell', {
attr: {
ref: 'A1:E1'
}
}));
mergeCells.attr('count', mergeCells.attr('count') + 1);
function _createNode(doc, nodeName, opts) {
var tempNode = doc.createElement(nodeName);
if (opts) {
if (opts.attr) {
$(tempNode).attr(opts.attr);
}
if (opts.children) {
$.each(opts.children, function (key, value) {
tempNode.appendChild(value);
});
}
if (opts.text !== null && opts.text !== undefined) {
tempNode.appendChild(doc.createTextNode(opts.text));
}
}
return tempNode;
...