While Adding Second Sheet in the Export to Excel , the Second sheet is not getting customizedformat
While Adding Second Sheet in the Export to Excel , the Second sheet is not getting customizedformat
Swapnil90PG
Posts: 1Questions: 1Answers: 0
Hi Team,
I am using the datatable js in my project , for the export to excel . below is sample template code
searchDataTable = $('.table2excel').DataTable({
dom: 'Bfrtip',
"paging": false,
"ordering": false,
"info": false,
"searching": false,
columnDefs: [{ //Start BUG 3705
targets: "txtcls",
"render": function (data, type, row) {
return "\u200C" + data;
}
}], //End BUG 3705
"buttons": [
$.extend(true, {}, buttonCommon, {
extend: 'excelHtml5',
filename: 'Budget Builder',
messageTop: null,
title: null
, customize: function (xlsx) {
addSheet(xlsx, '#table1', null, 'sheet2', '2');
var sheet = xlsx.xl.worksheets['sheet1.xml'];
//addSheet(xlsx, '#example2', null, 'sheet2', '2');
$('c[r=B1]', sheet).attr('s', '0');
$('c[r=A2]', sheet).attr('s', '2');
$('c[r=A3]', sheet).attr('s', '2');
$('c[r=A4]', sheet).attr('s', '2');
$('c[r=A5]', sheet).attr('s', '2');
$('c[r=A6]', sheet).attr('s', '2');
$('c[r=A7]', sheet).attr('s', '2');
$('c[r=A8]', sheet).attr('s', '2');
$('c[r=C2]', sheet).attr('s', '2');
$('c[r=C3]', sheet).attr('s', '2');
$('c[r=C4]', sheet).attr('s', '2');
$('c[r=C5]', sheet).attr('s', '2');
$('row:eq(9) c', sheet).attr('s', '7');
var sheet2 = xlsx.xl.worksheets['sheet2.xml'];
$('c[r=B1]', sheet2).attr('s', '0');
$('c[r=A2]', sheet2).attr('s', '2');
$('c[r=A3]', sheet2).attr('s', '2');
$('c[r=A4]', sheet2).attr('s', '2');
$('c[r=A5]', sheet2).attr('s', '2');
$('c[r=A6]', sheet2).attr('s', '2');
$('c[r=A7]', sheet2).attr('s', '2');
$('c[r=A8]', sheet2).attr('s', '2');
$('c[r=C2]', sheet2).attr('s', '2');
$('c[r=C3]', sheet2).attr('s', '2');
$('c[r=C4]', sheet2).attr('s', '2');
$('c[r=C5]', sheet2).attr('s', '2');
$('row:eq(9) c', sheet2).attr('s', '7');
}
})
]
});
.. But the I have no control on the second sheets formatting , even number data are getting rendered as string. Could u please suggest
Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.
Answers
This thread talks about adding a second sheet - so it would be worth looking at that. If that doesn't help, we're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.
Cheers,
Colin