How would you export it to xls? ActiveX Excel controller ("in my time this was called COM", etc)? Open source library?
/Applications/LibreOffice.app/Contents/MacOS/soffice --headless --convert-to xlsx file.csv
Note, though, that some conversion errors can still occur (I've seen one personally a long time back).A resource hog, though - had to close it off into its own container, lest it gobble up all available RAM.
[0]: http://xlsxwriter.readthedocs.io/ https://pypi.python.org/pypi/XlsxWriter
[1]: https://openpyxl.readthedocs.io/ https://pypi.python.org/pypi/openpyxl
One nice feature with openpyxl is that it can work together with excel template files. So I can create a template in excel with whatever looks and features I want and then use openpyxl to populate those templates with data.