Export visible columns PLUS one extra column to excel

Export visible columns PLUS one extra column to excel

patricknypatrickny Posts: 15Questions: 7Answers: 0

I use the following code to export Visible Columns only to excel. It works great!
buttons: [ {
extend: 'excel',
exportOptions: {
columns: ':visible'
}
}, 'print',],

I am looking to add one additional column, which is hidden, to the export. So, in essence, it'll be exporting all the visible, plus column 3 and 4, which are hidden.

Is this possible?

Replies

  • patricknypatrickny Posts: 15Questions: 7Answers: 0

    Got it!
    Add class 'hc' (or any class, really) to the <th> and <td> of the extra column which i will hide in datables -- and add .hc to the columns in the export.

                exportOptions: {
                    columns: [':visible', '.hc']
                }
    
  • allanallan Posts: 63,451Questions: 1Answers: 10,465 Site admin

    Yup - that's how to do it. Nice one.

    Allan

Sign In or Register to comment.