custom Order column when export to excel

custom Order column when export to excel

WiliWili Posts: 7Questions: 1Answers: 0
edited March 2021 in Free community support

Hi @colin ,I have another question ,
when i want to export the data, how to reorder the data only for excel document ?
i want the result on the excel file is ordered by column 15.
Below is my partial code:

"buttons": [{
                "extend": 'excelHtml5', "text":'Export to Excel',"className": 'btn btn-secondary',
                exportOptions : {
                    modifier : {
                        // DataTables core
                        order : 'index', // 'current', 'applied',
                        //'index', 'original'
                        page : 'all', // 'all', 'current'
                        search : 'none' // 'none', 'applied', 'removed'

                    columns: [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 ]

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


  • colincolin Posts: 13,295Questions: 0Answers: 2,272

    You can modify the exported display values with orthogonal data but that's not so easy with the order.

    You would need to create a custom ordering plugin, force a draw with draw(), do the export, then pop() that plugin with a final draw() to get the table back to how it was.


Sign In or Register to comment.