Multiple DataTable Export in to Multiple worksheet
Multiple DataTable Export in to Multiple worksheet

How to export multiple datatables in to multiple worksheets in single Excel workbook on single click using Datatable export buttons. Please help me.
Answers
You would need to use the
customize
callback of theexcelHtml5
button type to modify the XLSX XML that Buttons creates. Buttons does not create multiple worksheets out of the box.Allan
I tried tweaking the buttons.html5.js successfully to export multiple datatables in to multiple worksheets in single Excel workbook on single click using Datatable export buttons. Before posting the code here, I would like to have it reviewed by Allan to see if it is correct and if yes, can it be included in the future releases for the benefit of the community
Hi,
Paste it in here, and I'll be happy to take a look
Allan
/*I've tested exporting 6 datatables to 6 separate worksheets in a single workbook.My Buttons config has an extra option 'multitables' specified for the solution to work which basically has TableId:Sheetname and looks like this:
extend: 'excelHtml5',
multitables:{PL:'Profit',CL:'Liabilities',BS:'Assets',FF:'FundFlow',WC:'WkCap',FP:'FinPos'},
Since there seems to be a limitation on the characters allowed in this message unable to paste the entire contents of file buttons.html5.js, I am pasting the entire class DataTable.ext.buttons.excelHtml5 where the changes have been made. Also changed Relationship Id="rId0" instead of rId2 in excelStrings array which is not pasted here due to limitation on pasting max chars here
*/
//====Start of code pasted from buttons.html5.js===
DataTable.ext.buttons.excelHtml5 = {
className: 'buttons-excel buttons-html5',
};
====End of code pasted from buttons.html5.js===
//The "xl/workbook.xml": of the excelStrings object has:
//===
'<sheets>'+
'<sheet name="sheet1" sheetId="1" r:id="rId1"/>'+
'</sheets>'+
//===
And also, the "xl/_rels/workbook.xml.rels":
'<Relationship Id="rId0" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml"/>'+
@mukeshp hello. how does this work? I copied your modified code and followed your instructions but I still don't know how to produce multiple worksheets in one .xlsx file.
Did you copy the new buttons.html5.js with the excelStrings changes?
Do you have your code or a sample fiddle to analyse the issue you are facing?