Buttons export to excel visible columns

Buttons export to excel visible columns

batspybatspy Posts: 3Questions: 1Answers: 0
edited July 2016 in Free community support

Hello,

I am using the following code:

$('#tbl').DataTable( {
        "dom": 'Blpfrti',
        "tableTools": {
            "sRowSelect": "single",
            "aButtons": [{
                "sExtends": "collection",
                "mColumns": "visible",
                "oSelectorOpts": { filter: 'applied', order: 'current', page: 'all' },
            }],
        },
    buttons: [
            'copy', 'excel', 'csv', 'pdf'
        ]
    } );

I am trying to export to excel the visible rows/columns/filtered data. Everything works fine but it doesn't filter the columns. Whatever I may do it keeps showing all the columns and not only the visible.

Am I doing something wrong?

Edited by Allan - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

Answers

  • allanallan Posts: 62,301Questions: 1Answers: 10,216 Site admin

    It looks like you are mixing TableTools and Buttons together - I would very strongly encourage you to remove TableTools entirely. This example shows how to do it in Buttons.

    Allan

This discussion has been closed.