Format Excel file from Export

Format Excel file from Export

arkofdanarkofdan 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!

Answers

  • allanallan Posts: 63,844Questions: 1Answers: 10,518 Site admin

    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

  • eddeleddel Posts: 2Questions: 0Answers: 0

    Is there any updates on this?

  • allanallan Posts: 63,844Questions: 1Answers: 10,518 Site admin

    No sorry. It will likely be a few months before this is available.

    Allan

  • dclar43dclar43 Posts: 47Questions: 13Answers: 2

    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.

  • eddeleddel Posts: 2Questions: 0Answers: 0
    edited March 2016

    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

  • julielbeltzjulielbeltz Posts: 1Questions: 0Answers: 0

    Checking back on status of this. Need hyperlinks in datatables somehow exported to Excel.

  • allanallan Posts: 63,844Questions: 1Answers: 10,518 Site admin

    You can use the customize function of the excelHtml5 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

  • ttse23ttse23 Posts: 10Questions: 3Answers: 0

    How would you do that?

  • kthorngrenkthorngren Posts: 21,568Questions: 26Answers: 4,996

    This gives an example of modifying the cell's background in a particular column.
    https://datatables.net/extensions/buttons/examples/html5/excelCellShading.html

    Kevin

  • ttse23ttse23 Posts: 10Questions: 3Answers: 0

    I meant exporting hyperlinks to excel

  • allanallan Posts: 63,844Questions: 1Answers: 10,518 Site admin

    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

This discussion has been closed.