[HOWTO] Working export to PDF and XLSX (HTML5) for datatables.net-vue3
[HOWTO] Working export to PDF and XLSX (HTML5) for datatables.net-vue3
sfinktah
Posts: 1Questions: 0Answers: 0
This took ages to figure out, hope someone finds it's useful.
<script setup>
import JSZip from 'jszip';
window.JSZip = JSZip;
// https://stackoverflow.com/questions/77269854/pdf-generate-with-vfs-fonts/77270165#77270165
import * as pdfFonts from 'pdfmake/build/vfs_fonts';
import pdfMake from "pdfmake";
pdfMake.vfs = pdfFonts.pdfMake.vfs
import DataTable from 'datatables.net-vue3';
import DataTablesCore from 'datatables.net-dt';
import 'datatables.net-buttons';
import 'datatables.net-buttons/js/buttons.html5';
import 'datatables.net-buttons/js/buttons.print';
DataTable.use(DataTablesCore);
Those are the missing pieces from the examples in the documentation, and https://stackblitz.com/edit/datatables-net-vue3-extensions?file=src%2FApp.vue
Replies
Apologies. There is a full example with the export buttons available here. I'll add it to the documentation.
Allan