Excel export
Excel export
Hello, I have a lot of data in certain cells on DataTables. If the text is too long, I truncate the text with an ellipsis, but provide the full text in the HTML title attribute so the user still has access to the cells data on hover.
When I export, I notice that DataTables is exporting the ellipsis in the excel sheet.
My question is:
Is there a way to customize the export so that it prints the title attribute so the actual data is in the excel? Is there an option for this?
Thanks for the fantastic library!
Best
Answers
Sorry for duplicate question. I found what I was looking for here:
https://datatables.net/forums/discussion/33305/exporting-data-from-the-source-data-rather-than-from-a-displayed-table-cell
Further help found in the Documentation link:
https://datatables.net/extensions/buttons/examples/html5/outputFormat-orthogonal.html
My solution:
In my columnDefs render function I have this. note It's not the prettiest, since I have a nested ternary operator:
render: function ( data, type, row ) {
return type === 'export' ? data : (data.length > 9 ? data.substr( 0, 9 ) +'…' : data);
}
... but it does truncate the text (if too long) in the cell, but will also export the full data to the excel sheet.
I hope this saves someone some time!