DataTables 1.13 ES6 buttons plugin jszip and pdfmake integration
DataTables 1.13 ES6 buttons plugin jszip and pdfmake integration

Hello,
after updating the DataTables packages yesterday, I encountered some problems. I changed my import from
import JSZip from 'jszip';
import ButtonHtml5 from 'datatables.net-buttons/js/buttons.html5';
window.JSZip = JSZip;
ButtonHtml5(window, $);
to
import JSZip from 'jszip';
import 'datatables.net-buttons';
window.JSZip = JSZip;
I found the new implementation in your git repository https://github.com/DataTables/Dist-DataTables-Buttons. But my app still throws this error:
buttons.html5.mjs:18 Uncaught ReferenceError: jszip is not defined
at _jsZip (buttons.html5.mjs:18:2)
at Object.available (buttons.html5.mjs:976:45)
at Buttons.excel (dataTables.buttons.mjs:1875:55)
at toConfObject (dataTables.buttons.mjs:1066:18)
at Buttons._resolveExtends (dataTables.buttons.mjs:1101:19)
at Buttons._expandButton (dataTables.buttons.mjs:587:20)
at Buttons._expandButton (dataTables.buttons.mjs:646:10)
at Buttons.add (dataTables.buttons.mjs:178:8)
at Buttons._constructor (dataTables.buttons.mjs:493:9)
at new Buttons (dataTables.buttons.mjs:101:7)
Is there a way to include jszip or pdfmake back to buttons again?
Also will there be a new documentation how to implement DataTables into an ES6 project?
I'm currently working with vite and with the following DataTables packages:
"datatables.net": "1.13.0",
"datatables.net-buttons": "2.3.1",
"datatables.net-responsive": "2.4.0",
"datatables.net-select": "1.5.0",
"jszip": "3.10.1",
"pdfmake": "0.2.6",
Maybe someone can give me some hint how to implement it with DataTables 1.13 . Thanks and have a nice day/night.
This question has accepted answers - jump to:
Answers
Some additional information:
1.) I only want to include the excel export option on one site (it is an extra .js file) and on another side I want to include the excel/pdf export option.
2.) DataTables will load if I changed the position of the JSZip import like this
But on my app the button won`t show up. The buttons are defined like this:
There is no error on the console nor a error on the DataTables debug plugin (I can't open Version check there because of our cors policy).
For our app we will go back to version 1.12.1 and wait till there are some new information where my configuration error may be.
Should do the job.
Buttons adds two static methods for the setting of pdfMake and JSZip for exactly this sort of thing.
Allan
Hello allen,
sadly it isn't working like expected. My datatables-all-without-pdf.js:
still throws this error:
For my DataTable I need the following packages:
1. DataTables
2. Responsive
3. Colvis buttons
4. Excel export buttons
5. Select
Here is the content of the vite generated file:
If you need more information, please ask. I will try to deliver them asap.
My DataTable code:
I deleted some parts and changed some naming for security reasons. We did not change the DataTable code after updating to 1.13.
Hi,
I've just released Buttons 2.3.2 to npm which should address the issue you are seeing. Here is an example showing Excel and PDF export
Allan
Hey allen,
thanks for the update! It is working like expected. Thanks for the fast replies and the help!
Maybe a blog post with an updated ES6 integration manual would be helpful for other users.
Have a nice day/night!
Yes, blog post and a few documentation updates are coming
Allan