How to add CRLF to last line of CSV export?
How to add CRLF to last line of CSV export?
Is there a way to make the last line of the results of the HTML5 CSV button also have a CRLF after it? For example, if you go to the HTML5 Exports example page at https://datatables.net/extensions/buttons/examples/html5/simple.html and click on the CSV button and save the file and then open it in something like Notepad++, all the lines have a CRLF after them except for the last line. The reason I ask is I have customers who use the CSV button to export a file and then upload that file to a 3rd party vendor. The 3rd party vendor system ignores the last line because there's no CRLF after it like all the other lines.
Thanks,
Matt
This question has an accepted answers - jump to answer
Answers
Just a followup - when I try the same thing using DataTables 1.9.x and TableTools 2.0.2, the Flash CSV button puts a CR on the last line and the 3rd party vendors don't have an issue with the file. But I'm wanting to get away from the Flash stuff and use the new DataTables and Buttons.
Matt
Hi @Matt SQLR ,
This is the RPC for CVS files here - see 2.2, "The last record in the file may or may not have an ending line break", so it seems like those 3rd party vendors are non-compliant.
A workaround would be to add an empty row on the end, something like this.
Hope that does the trick,
Cheers,
Colin
Hi @colin,
Thank you very much - that should do the trick!
Matt