is there any example for writing this format? I need to write several thousand numeric values, what is still amazing fast. I need to write a header with quoted result names, because the names are containing whitespaces. I would like to write the header like this:
"result name 1" "result name 2" "result name 3" etc.
The preview is correct, but when open the *.csv file in a text editor I get this:
"""result name 1""" """result name 2""" """result name 3""" etc.
Do I need to assign some kind of cell format before filling the cells with strings?
Now, I am not sure I understand why you want to enclose a field like "result name 1" in quotes, just because it has whitespace. From the standard:
Fields containing line breaks (CRLF), double quotes, and commas
should be enclosed in double-quotes. For example:
"aaa","b CRLF
bb","ccc" CRLF
zzz,yyy,xxx
And that's what FlexCel does, but it does it automatically. If the field was named "result name 1" FlexCel would automatically add the quotes. But not for just whitespace.
Same, if you set a cell as "result name 1" (with quotes) FlexCel will enter exactly that in the field. (that is, the name with quotes). To do so, it must escape the quotes, and it does so byw writing """ instead of ".
The idea is that you shouldn't have to worry about the CSV escaping, FlexCel will take care of that. If you open the CSV file in Excel, it should have the same cell values as the original file had.
If you are trying to open the file in some other tool that requires quotes when there is whitespace, we can see to add an option for that. But such a tool wouldn't be able to open Excel-generated CSV files, as those don't quote whitespace.
thank you for your detailed explanations about writing the csv format. I found a code snippet by using the APIMate.exe tool. I got the idea of quoting the parameter names before I finally understood, that using a separator like ";" is solving the problem of parsing the header line when using parameter names which are containing whitespaces.
Basically the Save() method which allows me to set the text format/encoding and a separator char, is what I was missing. I also didn't see the csv topic in the tips & tricks section.