Format Excel file from Export
Format Excel file from Export
arkofdan
Posts: 2Questions: 1Answers: 0
Hi!
Thanks in advance all the help you can give me.
I am trying to format the excel file I got when exporting from datatables.
Right now I am doing this:
{
extend: 'excel',
exportOptions: {
columns: '.exportable',
stripHtml: false,
format: {
header: function ( data, columnIdx ) {
return '<span style="width: 300px; background-color:blue; color:white;">'+data+'</span>';
}
}
}
},
But it prints the html tags (encoding them) in the final excel.
I want to add some colors and styles to the excel file, and I am not sure how.
Thanks!
This discussion has been closed.
Answers
There is unfortunately no option for this at the moment. it is something I hope to add in a future release of Buttons, but it isn't currently possible.
Regards,
Allan
Is there any updates on this?
No sorry. It will likely be a few months before this is available.
Allan
In the mean time you can look into this resource. It's far from ideal but if it fits your application Excel will accept a copy+pasted HTML table and honor the formatting. As long as you work within the above confines. Aside from that I fiddled around with PHPExcel with some promising results. It allows the creation/modification of several Excel formats including formatting.
Thanks @dclar43!
I am now using the Excel Export in package in Laravel which is also using the PHPExcel. (y)
http://www.maatwebsite.nl/laravel-excel/docs/export
Checking back on status of this. Need hyperlinks in datatables somehow exported to Excel.
You can use the
customize
function of theexcelHtml5
button type to modify the XLSX file to suit your needs. You'd need to checkout the Open Spreadsheet standards to see how a hyperlink is embedded into an XLSX file, but it is now possible to modify the created file as you require.Allan
How would you do that?
This gives an example of modifying the cell's background in a particular column.
https://datatables.net/extensions/buttons/examples/html5/excelCellShading.html
Kevin
I meant exporting hyperlinks to excel
You'd need to read the Open Spreadsheet specification to find out how to embed links into its XML structure and then use the
customize
method as I mentioned above. I don't know what the XML required for the hyperlinks in Open Spreadsheet is I'm afraid.Allan