How to export a DataTable as an Excel file to be included in a Zip file ?
How to export a DataTable as an Excel file to be included in a Zip file ?
PBrockmann
Posts: 4Questions: 2Answers: 0
Hi all,
I am wondering what would be the best solution to export my selection from a datatable to an excel file to be included in a zip file.
For now, I have an ajax call that runs a php code to produce my zip file.
I need now to include a recall of the current selection (as an excel file).
Any idea to share ?
Thanks
Patrick
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Can your server-side create the Excel file as well? If so
rows().data()
is how to get the data to export.If you want to use the client-side generated file, you'd need to modify the
excelHtml5
button to give you the binary blob it creates for the Excel file and then send that to the server.Allan
Thank you Allan for your answer.
I have indeed send my datatable with rows().data() with a http ajax request to my php server where I have used Spout to generate a spreadsheet document.
References:
- A simple HTTP POST and GET Redirection Plugin for jQuery (https://github.com/mgalante/jquery.redirect)
- Spout is a PHP library to read and write spreadsheet files (CSV, XLSX and ODS), in a fast and scalable way (http://opensource.box.com/spout/)