Excel Button option not shown in SPFx webparts

Excel Button option not shown in SPFx webparts

KalimuthuKalimuthu Posts: 2Questions: 1Answers: 0
edited March 2021 in Free community support

Hi,

I want to export my data into excel.

when I'm using export option in data table. I'm getting export options like csv and print options only except excel button

how to solve this. I added all references for export options. help me to figure out this.

Note: Its not working only in SPFx webparts.

Here is my code.

$('#UserTimehseetExport').DataTable( {
dom: 'Bfrtip',
select: true,
destroy:true,
colReorder: true,
buttons: [
{
extend: 'collection',
text: 'Export Records',
buttons: [
'excel',
'csv',
'print'
]
}
]
} );


This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,142Questions: 1Answers: 2,586

    We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

  • allanallan Posts: 61,654Questions: 1Answers: 10,094 Site admin
    Answer ✓

    My guess is that you haven't loaded the JSZip library? Otherwise, as Colin says, we'd need a test case.

    Allan

  • KalimuthuKalimuthu Posts: 2Questions: 1Answers: 0

    Hi Allan,

    You were correct. The issue with the JSZip lib loading.

    instead of using cdn path i used the below.

    import * as JSZip from 'jszip';

    then before the datatable method call

    window["JSZip"] = JSZip;

    found the answer from the following discussion.

    https://datatables.net/forums/discussion/63040/can-we-integrate-datatable-with-excel-export-in-a-sharepoint-spfx-webpart

This discussion has been closed.