Looking for guidance on how to handle an issue with column headers.
Issue:
Microsoft Excel registers itself as the default handler for CSV files. There is a known issue within excel, that when the first column of the first row starts with the chars ID, the user will experience an "SYLK: File format is not valid" error message.
Workaround:
To mitigate this, Microsoft's workaround to is to place an apostrophe before the field.
Looking at the documentation for CsvHelper, I seem to be missing how to go about this.
Suggestion:
Ideally, it would be nice if CsvHelper would check for the Display Attribute from System.ComponentModel to get header information. Looking through the source, it looks as though CsvHelper just looks at PropertyName?
Is this for reading or writing or both?
Writing
You can control over the headers. If you want the first header to be ID you can just map it to 'ID instead.
You can either create a map http://joshclose.github.io/CsvHelper/mapping/ or there are attributes you can use that aren't documented yet. [Name("'ID")] They are in namespace CsvHelper.Configuration.Attributes
Awesome Thanks!
You can control over the headers. If you want the first header to be
IDyou can just map it to'IDinstead.You can either create a map http://joshclose.github.io/CsvHelper/mapping/ or there are attributes you can use that aren't documented yet.
[Name("'ID")]They are in namespaceCsvHelper.Configuration.Attributes
This should make its way into the documentation 馃槃
http://joshclose.github.io/CsvHelper/mapping/ this page is now a 404
Most helpful comment
This should make its way into the documentation 馃槃