Multiple Excel Buttons

Multiple Excel Buttons

LeekmanLeekman Posts: 2Questions: 1Answers: 0

Hello

I'm trying to allow multiple excel buttons on datatable.

The point of this feature is to allow the user to filter and export specific data with only one click.

I tried this code :

{
                        extend: 'excel',
                        footer: true,
                        header:true,
                        exportOptions: {
                            columns: [0,2,3,4,5,6,7]
                        }
                    }
                    {
                        extend: 'excel',
                        text:'north',
                        footer: true,
                        header:true,
                        exportOptions: {
                            columns: [0,2,3,4,5,6,7]
                        },
                        rows:'.north'
                    }

but the second excel button does not trigger.

Is there a way to achieve what i'm trying to do ?

I also tried to fill the search filter then trigger the excel export but i didn't succeed aswell.

Thanks for any advice or solution

Regards,

Valentin

This question has an accepted answers - jump to answer

Answers

  • F12MagicF12Magic Posts: 109Questions: 0Answers: 28

    I could be wrong, but I think you can have only one excel button.
    For your specific case, I would suggest using the ColVis button to allow the user to choose which columns he want to export. Then with the excel button use the exportOptions of the excelHtml5 button to only export the visible columns.
    Something like:

    $(document).ready(function() {
        $('#example').DataTable( {
            dom: 'Bfrtip',
            buttons: [
                {
                    'colvis'
                },
                {
                    extend: 'excelHtml5',
                    exportOptions: {
                        columns: ':visible'
                        }
                }
            ]
        } );
    } );
    
  • allanallan Posts: 63,815Questions: 1Answers: 10,517 Site admin
    Answer ✓

    Having two buttons should work and it appears to do so for me here: http://live.datatables.net/lesehamo/1/edit .

    Can you link to a test page showing the issue (per the forum rules) please?

    Allan

  • LeekmanLeekman Posts: 2Questions: 1Answers: 0

    It turns out it was due to my CSS. I actually hate myself right now.

    Thanks though just applying the css and js included with the CDN did the work

    Thanks a lot for the quick answer

    Valentin

This discussion has been closed.