After hours of searching and reading other related questions but that have not helped me at all, I come here for help.
I have a table with columns that have looooong names, to avoid spacing problems I used tooltips and shortened header names, but when exporting to csv, I would like to export the whole name of the header not the shortened version. (Not all the columns have long names)
Here is an example:
So for instance, for the second column (U.N)
I would like that when I export the table, the header is displayed as: Full User Name
.
What I've tried:
buttons: [
{
extend: 'csv',
exportOptions: {
columns: [1],
format: {
body: function (data, rowIdx, colIndex, cellNode) {
if (colIndex == 1) {
data = "Full User Name"
};
return data;
}
}
},
charset: 'utf-8',
bom: true,
}
]
I basically tried to change the value manually for the second column [1]
without success.
How could I do that?
CodePudding user response:
You should use:
format: {
header: function() {}
}
instead of:
format: {
body: function() {}
}