Unexpected csvHtml5 export behavior
Unexpected csvHtml5 export behavior
Hello, I'm using the buttons extension (specifically the csvHtml5 feature), and I believe there is an issue when exporting tables with commas in cell values. The resulting CSV will split cells into different values because of the commas. I believe that the previous flash plugin would automatically trim the commas in order to avoid that unexpected behaviour.
Export this example and see how the Salary is splitted in two (or three) cells: https://datatables.net/extensions/buttons/examples/html5/simple.html
How can I avoid that? I tried to define a cellRender function (or something like that) in the button settings to remove the commas before exporting, but I failed.
Thank's for reading.
This question has an accepted answers - jump to answer
Answers
The current release of Buttons has an error in this button type whereby it should, but doesn't, specify a field boundary. This can be corrected in the current release by using the
fieldBoundary
option:That, and the fact that if there is a field boundary it wouldn't be escaped, was addressed in this commit and will be included in the next release.
Allan
Thanks! It's working fine now.
Would you mind telling me how can I format cells (and column header, if possible) before exporting?
Something like fnCellRender function in the flash export will do.
You need to use the
columns.render
option as a function and thebuttons.exportData()
method's ability specify what orthogonal data it should request (through theorthogonal
property.Allan