javascript - How to add header with colspan row in excel export - DataTable -


i'm using datatable excel export button. i've added header in excel export using javascript. but, how add row merge cells in header of excel data? , how can add header in every page of excel file?

javascript

var otable = $('#dataaksesad').datatable({ dom: 'bfrtip', buttons: [     {         extend: 'excelhtml5',         text: 'cetak',         title: "monitoring ad_"+date,         customize: function (xlsx) {             var sheet = xlsx.xl.worksheets['sheet1.xml'];             var numrows = 5;             var clr = $('row', sheet);              //update row             clr.each(function () {                 var attr = $(this).attr('r');                 var ind = parseint(attr);                 ind = ind + numrows;                 $(this).attr("r",ind);             });              // create row before data             $('row c ', sheet).each(function () {                 var attr = $(this).attr('r');                 var pre = attr.substring(0, 1);                 var ind = parseint(attr.substring(1, attr.length));                 ind = ind + numrows;                 $(this).attr("r", pre + ind);             });              function addrow(index,data) {                 msg='<row r="'+index+'">'                 for(i=0;i<data.length;i++){                     var key=data[i].key;                     var value=data[i].value;                     msg += '<c t="inlinestr" r="' + key + index + '">';                     msg += '<is>';                     msg +=  '<t>'+value+'</t>';                     msg+=  '</is>';                     msg+='</c>';                 }                 msg += '</row>';                 return msg;             }               //insert             var r1 = addrow(1, [{ key: 'a', value: 'monitoring log ad' }]);             var r2 = addrow(3, [{ key: 'a', value: 'nama user' }, { key: 'c', value: ': '+username }]);             var r3 = addrow(4, [{ key: 'a', value: 'nama pusat' }, { key: 'c', value: ': pusat1' }]);              sheet.childnodes[0].childnodes[1].innerhtml = r1 + r2+ r3+ sheet.childnodes[0].childnodes[1].innerhtml;             $('row c[r*="1"]', sheet).attr( 's', '2' );             $('row c[r*="3"]', sheet).attr( 's', '2' );             $('row c[r*="4"]', sheet).attr( 's', '2' );         }     } ] }); 

i hope there can me. in advance.


Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -