Editing cells just before exporting to Excel/PDF/...
Editing cells just before exporting to Excel/PDF/...

Can you guys help/show me how to edit certain cells just before exporting my table to for example Excel (the same goes for exporting to PDF I guess).
Below you'll find my code of the export button to Excel:
// Define export buttons for DataTables
var exportButtons = [
{
extend : 'excel',
className : 'fa fa-file-excel-o',
defaultContent: '',
title : $('h1').html(),
text : '',
exportOptions : {
columns: ':visible'
},
WHAT_CODE_GOES_HERE : function (data, type, row, meta) {
// I WANT TO EDIT MY CELLS...
}
},
...
];
If it's not possible in the way I want to do it (example above), how do I than edit cells before exporting?
The reason for editing my cells before exporting is because I use <input>
s and <select>
s with certain data
attributes that I need the info from when exporting. The input
s do not show anything when exporting at the moment and the select
s show all possible values when exporting :(
Hope you guys can help me out!
If you got the latest dev build of Buttons dev-1.1.0 or the newly released Buttons, the following will work:
// Define export buttons for DataTables
var exportButtons = [
{
extend : 'excel',
className : 'fa fa-file-excel-o',
defaultContent: '',
title : $('h1').html(),
text : '',
exportOptions : {
columns: ':visible',
format: {
body: function(data, column, row) {
// DO SOMETHING WITH DATA
return data;
}
}
},
},
...
];
@Allan When can we expect Buttons update to support format
, instead of using dev-1.1.0 build?
Replies
@Allan When can we expect Buttons 1.1.0 in the Download builder, since 1.1.0 supports
format
..If we can somehow use dev-builds in the Download builder, I'm happy aswell :)
Awaiting your response.
Regards TK
Buttons is updated to 1.1.0 and support
format
This is correct - Buttons 1.1.0 is now available. Example available here.
There is no option for that, and it is not something I plan to add due to the strain (disk space and processor) it would put on the DataTables server.
Allan