Export XLS/XLSx to TXT/CSV

I need to export a XLS to TXT / CSV.


Is there any Flexcel function that exports the spreadsheet generated in these formats or do I need to write a code to read the value of each cell and write to a TXT / CSV file?

Hi,

XlsFile.Save can save to csv/tsv. You can use for example:
http://www.tmssoftware.biz/flexcel/doc/vcl/api/FlexCel.Core/TExcelFile/Save.html#texcelfilesavestring-tfileformats-char-tencoding

You would call it like this:

xls.Save('myfile.csv', TFileFormats.Text, ',', TEncoding.UTF8);

The encoding might be UTF8, Unicode, ASCII or ANSi depending on how you want to save the file. The separator is normally #9 (tab) ',' (comma) or ';' (for non-english versions of Excel).

Note that in APIMate, there is also a button at the left "Save as CSV" which will show you this line too if you click it.

The "save" overload covers most needed cases. If you need more options, or if you want to save as prn (that is, fixed length columns instead of comma separated values, where each filed has a fixed length), you can use xls.Export: 
http://www.tmssoftware.biz/flexcel/doc/vcl/api/FlexCel.Core/TExcelFile/Export.html

Export can do all Save can do, but also provides more options, and lets you save as csv or prn.
That's exactly what I need.

Thank you