Export specific columns from datatables using column header
Export specific columns from datatables using column header
![v3nky](https://secure.gravatar.com/avatar/c0ccfc60436ed2c5d4b73ef409a08e6b/?default=https%3A%2F%2Fvanillicon.com%2Fc0ccfc60436ed2c5d4b73ef409a08e6b_200.png&rating=g&size=120)
Is it possible to export specific columns from datatables using column header instead of column index?
Below is example using column index.
{ extend: 'excel', text: 'Exportieren InfoDatei (xls/xlsx)',title:'BerichtInfo_Datei_Export',
exportOptions: {
columns: [1,2,3,4,5,6,7,9,66,67,30,26,68,28]
},
filename: function(){
var date = new Date();
var n = date.getFullYear() + "" + (date.getMonth()+01) + "" + date.getDate() + "" + date.getHours() + "" + date.getMinutes() + "" + date.getSeconds();
return 'BerichtInfo_Datei_Export_' + n;
}
Instead I would like to use column names. Please advise how can I use column names.
This question has an accepted answers - jump to answer
Answers
Hi @v3nky ,
This example here shows the export options, and shows that the columns can be specified by the
column-selector
. This section here shows how to use the column names.Hope that helps,
Cheers,
Colin
`{ extend: 'excel', text: 'Exportieren InfoDatei (xls/xlsx)',title:'BerichtInfo_Datei_Export',
exportOptions: {
/* columns: [1,2,3,4,5,6,7,9,66,67,30,26,68,28] */
columns :[
{name:"REPORTING_ID"}
]
I have tried this but did not work.
Here is an example using the links that Colin provided.
http://live.datatables.net/japeyavu/1/edit
Looks like the columns listed in you exportOptions is not the correct format. Also did you set the
columns.name
option as shown in Colin's second link?Kevin
Thank you kthorngren . I have corrected columns naming format in export options and then it worked. Thank you once again.