Datatable Excel and PDF button not working

Viewed 9583

I don't know why my Datatable button are not working. Copy and CSV Buttons works well, but Excel and PDF did not work.

I have all npm modules installed, and i have all of them already imported

$ from 'jquery'
import 'jszip'
import 'datatables.net'
import 'datatables.net-bs'
import 'datatables.net-responsive'
import 'datatables.net-buttons'

import 'datatables.net-buttons/js/buttons.html5.js'
import 'datatables.net-buttons/js/buttons.colVis.js'
import 'datatables.net-buttons/js/buttons.flash.js' 
import 'datatables.net-buttons/js/buttons.print.js'

And here is my Datatable config:

$('#dataTable').DataTable({
                    responsive: true,
                    "language": datatableBR,
                    "dom": '<"html5buttons"B>lTfgt<"row"<"col-md-6"i><"col-md-6"p>>',
                    "buttons": [
                { extend: 'copy'},
                {extend: 'csv'},
                {extend: 'excel', title: 'ExampleFile'},
                {extend: 'pdf', title: 'ExampleFile'}
            ]
                })

Anyone knows why these two buttons don't work?

Thanks a lot!!

@EDIT - Solution

I think datatables.net and datatables.net-bs was entering in conflict. I'm using only datatables.net-bs now. I installed too "jszip" from NPM using --save.

=)

3 Answers

Try to include below script to run excel and pdf.

For excel add this script: import 'datatables.net-buttons/js/buttons.flash.min.js'

For pdf add these script: import 'datatables.net-buttons/js/pdfmake.min.js'

Related