how to split column content when exporting

how to split column content when exporting

hitesh97hitesh97 Posts: 1Questions: 1Answers: 0

In my datatables there is a column named serial number which is in format ab123, and for exporting i am using following code,

$('#example').DataTable( {
"dom": 'Bfrtip',
"buttons": [
    {
            extend: 'csvHtml5',
            text: 'download',
            exportOptions: {
                columns: [ 0, 1, 2, 3, 4 ]
            },
            title: 'exported'
        }
]

} );
now, in according to current code when i export i get exactly the same content of table, but what i want is get serial number as 2 diffrent columns in exported report namely serial and number. ie original serial number = ab123 as serial = ab and number = 123.

i have found tutorial given on https://datatables.net/extensions/buttons/examples/html5/outputFormat-function.html

but i am not sure wheather it will allow me to split the column? what should i do here? thank you for your suggestions

also i have looked at https://stackoverflow.com/questions/30606743/datatables-cell-contents-split-into-2-columns-on-export but its not much help.

Answers

  • colincolin Posts: 15,142Questions: 1Answers: 2,586

    Hi @hitesh97 ,

    One option would be to have a couple of hidden columns in the table that you use to store the split values, and you export those and hide the visible one. That's using orthogonal data and shouldn't be too tricky. Shout if you need more info.

    Cheers,

    Colin

This discussion has been closed.