How to export XLSX with only visible columns?

How to export XLSX with only visible columns?

SickPuPSickPuP Posts: 13Questions: 6Answers: 0

I am using the colvis and excel buttons for my DataTable. The excel file works fine and the column visibility is working fine. However, when I hide a couple columns and try to export those columns still appear in the output file. I only want to export columns that are visible. Any ideas?

Answers

  • F12MagicF12Magic Posts: 109Questions: 0Answers: 28

    Hi SickPuP,
    in the exportOptions you can define columns: ':visible'
    More info can be found through the excelHTML5 page.

    Example:

    buttons: [ 
        {
            text: 'Export to XLS',
            extend: 'excelHtml5',
            exportOptions: {
                columns: ':visible'
            }
        }
    ]
    
This discussion has been closed.