How to use excel button in SPFx

How to use excel button in SPFx

Deep DhanotiyaDeep Dhanotiya Posts: 2Questions: 1Answers: 0

Hi,

I need to use excel button in SPFx to export table in excel format. But using buttons npm packages i am not able to use excel button.

Can anyone please let me know that how we can use excel button in SPFx.

Thanks

Answers

  • colincolin Posts: 15,237Questions: 1Answers: 2,599

    This thread should help, it's asking the same thing.

    Cheers,

    Colin

  • Deep DhanotiyaDeep Dhanotiya Posts: 2Questions: 1Answers: 0
    edited July 2020

    $('#reports').DataTable({
    "stripeClasses": [
    'odd', 'even'
    ],
    columns: [
    { title: "Item#" },
    { title: "Min level" },
    { title: "Max level" },
    { title: "Currnet on hand inventory" },
    { title: "Pending quantity to receive" },
    { title: "Category" },
    { title: "Fixed location" }
    ],
    'columnDefs': [{
    'targets': "nosort",
    'orderable': false
    }],
    dom: 'Bfrtip',
    buttons: [
    'excel'
    ]
    });

    In above code while using "buttons" getting error on that. Is there any solution for that?

  • colincolin Posts: 15,237Questions: 1Answers: 2,599

    Without knowing what the error is, it's hard to say... Can you link to your page so we can take a look, please,

    Colin

  • JFUJFU Posts: 4Questions: 1Answers: 0

    Hello, Buttons settings are not available in SPFx,

    Could not find a declaration file for module 'datatables.net-buttons-dt'. '....../node_modules/datatables.net-buttons-dt/js/buttons.dataTables.js' implicitly has an 'any' type.
    Try npm i --save-dev @types/datatables.net-buttons-dt if it exists or add a new declaration (.d.ts) file containing declare module 'datatables.net-buttons-dt';ts(7016)

    I'm try to install @types/datatables.net-buttons-dt but do not exists

  • colincolin Posts: 15,237Questions: 1Answers: 2,599

    This SO thread should help, there's several techniques to avoid this error,

    Colin

  • JFUJFU Posts: 4Questions: 1Answers: 0

    In my case, I realized that I was importing npm i --save-dev @types/datatables.net-buttons-dt insted of npm i --save-dev @types/datatables.net-buttons (without -dt)

This discussion has been closed.