Export hyperlinks to Excel.
Inspired by https://stackoverflow.com/questions/40243616/jquery-datatables-export-to-excelhtml5-hyperlink-issue/49146977
This patch extends the special formatting capability of the Excel exporter to detect the "=FUNCTION(...)" signature customary in Excel, specifically for hyperlinks.
This PR does not attempt to solve the broader hyperlink rendering issue, though along the lines of the fourth example at https://datatables.net/reference/option/columns.render#Examples, a user could add a renderer for a custom 'excel' orthogonal:
$('#example').dataTable( {
columnDefs: [ {
render: {
display: function ( data, type, row, meta ) {
return '<a href="'+data+'">Download</a>';
},
excel: function ( data, type, row, meta ) {
return '=HYPERLINK("'+data+'",'"Download"')';
},
}
}]
});
then configure the export button to use it:
$('#report').dataTable({
buttons: [{
extend: 'excel',
exportOptions: {
orthogonal: 'excel',
},
}]
});
That's awesome - thank you for this.
I'm not going to pull it in immediately as I'd like to sync this up with the same ability in pdf export, and I'd like to think about the implementation a little, but I think others will find this really useful.
Absolutely. I still need to copy this logic into buttons.flash.js, write some tests, and as I woke up this morning I remembered that the "t" attribute needs to be set to "str". Definitely some polishing to do yet, but I wanted to get the core up for review.