How to create PDF or XLS?
How to create PDF or XLS?
Short Description: I've been unable to get Tabulator to create a PDF or Excel spreadsheet. I consistently get ReferenceError no matter what I try.
Long Description I've been trying to get Tabulator to create a PDF or Excel spreadsheet but I consistently get ReferenceError: jsPDF is not defined or ReferenceError: XLSX is not defined
Code For Excel I know I have XLSX working as I can create a spreadsheet directly with it but the tabulator download function fails with a ReferenceError. PDF gives the same result.
// this line works fine
XLSX.utils.book_new();
// this line fails with a ReferenceError
tablulatorRef.table.download("xlsx", "data.xlsx", {
sheetName: "Export to Excel"
});
Is there some way to pass the XLSX reference to Tabulator? I've been unable to find any sample that works for me. I feel like I'm missing some critical information to get this working.
Any help or a nudge in the right direction would be appreciated.
@benriga Did you solve this? I just posted a similar download issue. Seeing if you've solved and can provide some guidance.
https://github.com/ngduc/react-tabulator/issues/76#issuecomment-586407150
@psaban20 No. Sorry. I set it aside while I work on other things.
@benriga I'll keep trying and will let you know if I get anywhere.
I had the same issue and managed to solve by adding these three script tags in the head of my public/index.html file:
<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js"></script>
<script src="https://unpkg.com/[email protected]/dist/jspdf.min.js"></script>
<script src="https://unpkg.com/[email protected]/dist/jspdf.plugin.autotable.js"></script>
it does not work in a react Js project
It actually does work. Add the scripts to index.html
Download table data using the snippet.
if(tableRef!==null && tableRef.current!==null && tableRef.current!==undefined){ // @ts-ignore: tableRef.current.download("xlsx", "data.xlsx", {sheetName:"My Data"}); }