we're using CsvHelper library to export some information from our application, our clients normally use Excel to see the results
(sample of correctly opened data)
everything was working well until I tested my generated files in another machine with Format set on German(Austria) which I found out that excel would not parse it correctly anymore which is understandable because , has a different meaning in this format.
adding sep=, in the first line seems to fix the issue, but I couldn't find in CsvHelper documents that How we can achieve this. so the question is
How we can write delimiter like sep=, or anything with similar effect using CsvHelper library?
Inside the CsvWriter
class there is an aptly named WriteExcelSeparator()
that should do it.
Depending on how you use the library, you can even:
csv.Configuration.Delimiter = ",";
csv.Configuration.HasExcelSeparator = true;
If you use the WriteRecords
, use the second way, while if you use WriteHeader
/WriteRecord
use the first one.
csv.WriteExcelSeparator();
csv.WriteHeader<Simple>();
csv.WriteRecord( record );