Earlier quoted context omitted.
How would you export it to xls? ActiveX Excel controller ("in my time this was called COM", etc)? Open source library?
One useful trick is that you can rely on the headless version of LibreOffice to do the conversion, here on Mac for instance (but also work on Ubuntu with a slightly different call): /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.