Use Buttons for export of multiple datatables into single Excel file (multiple sheets)
Use Buttons for export of multiple datatables into single Excel file (multiple sheets)
genomer
Posts: 2Questions: 1Answers: 0
I have multiple datatables in a div and use Buttons extension to enable the export (PDF/Excel/CSV) for each of the tables. How can I add new button to allow the export of all tables into a single Excel file. I'd also like the content of each of the table to be exported into its own sheet inside the excel file.
I know that there were earlier discussion how to do that using TableTools, but not sure how to do it using Buttons.
This discussion has been closed.
Answers
From my point of view.. theres two options, one I recommend, and one I don't...
buttons.exportData()
to basically generate the data thats exported, exactly as it would be for an export, but instead of exporting it, save it to a variable. Do this for both tables, combine them, then export them using your own code to export them (Or just poke around the dataTables.buttons.js file and get the exact code it uses to export the content, since it is open source..1 is the way I would go, Its just the "correct" way to go, IMO..
2 is obviously a bit less work (At first glance, it might actually be more work though..), but its just not right to create an entire 3rd DataTable out of sight just to export data, then destroy it... I mean you're supposed to treat these things with respect! Not just use them for what you want , out of sight from everyone else, then toss them in the trash! They arent just pieces of code! (Kidding)
Genomer, were you able to get this working? I have been staring at my page with 12 tables containing unique data in each one trying to get 1 PDF output and am lost.
No, didn't get it to work yet. Once I extract data from individual tables using exportData(), I believe it would still require exploring and hacking to append it to the prospective report (Excel, PDF, etc). I plan to explore the 1st [recommended] approach though.
Would you mind sharing how you got the individual data with exportData? I've done some work directly with pdfmake and if I could get all the data, I think I could get it formatted to create the single pdf.