I created a CSV file using C #, and when I open this file in Excel, it shows double quotes in the cells.
When I open csv in Notepad ++, I see that there are quotes and everything looks right for me. Here is part of my csv:
"CertificaatNummer", "Data", "Inleg", "Getekend", "Ingangsdatum", "Betaalmethode", "Status", "Bonus", "Aankoopkoers", "Korting", "Garantiewaarde", "Betaalde termijnen", "Inleg nominaal", "Tweede naam", "Recht op bonus maand", "Begunstigde", "Product", "Incasserekening", "Uitbetaalrekening"
"126136", "some data with, a comma", "118.34", "True", "28-1-1999 00:00:00", "Cash", "C02", "0.00", "531,940", "0,000", "0.00", "0", "0.00", "", "False", "P.H. Bloemink", "Cash-Click", "", "260952095"
"137190", "other data", "0.00", "True", "23-12-1999 00:00:00", "Cash", "C02", "0.00", "660,620", "0,000", "0,00"
When I open this file in Excel, it treats the comma some data with, a commaas a new column. This way I get "Some data within one cell and a comma"in the cell for ants. As you can see, Excel doesn't care about double quotes.
This is what my code (simplified) looks like:
var content = new List<string>();
content.Add("\"Header 1\", \"Header 2\", \"Header 3\", \"Header 4\"");
content.Add("\"123456\", \"some data with, a comma\", \"118.34\", \"True\"");
using (var stream = new MemoryStream())
using (var writer = new StreamWriter(stream))
{
foreach (var line in this.content)
{
writer.WriteLine(line);
}
writer.Flush();
return stream.ToArray();
}
The question is, what part of my code do I need to change so that Excel displays my file correctly? I rather want to change my code and then do some tricks in Excel.