title: Line breaks in generated csv file driving me crazy
body: <p>I'm trying to make an export of some data i have (stored in a datatable). Some of those values have a linebreak in them. Now every time i try and import the file in excel (2010), the linbreaks get recognised as a new row, instead of an actual linebreak.</p>
  
  <p>I've searched for hours, seen many solutions, but i just can't seem to get it fixed.</p>
  
  <p>The way i output my csv file:
  (variable csvfile is a stringbuilder)</p>
  
  <pre><code>context.Response.Clear();
  context.Response.ContentType = "text/csv";
  context.Response.ContentEncoding = System.Text.Encoding.UTF8;
  context.Response.AppendHeader("Content-Disposition", "attachment; filename=" + name + ".csv");
  context.Response.Write(csvfile.ToString());
  context.Response.End();
  </code></pre>
  
  <p>When i open it with excel manually, it displays fine. But because excel 2003 doesn't support the file format, i have to import it. With the import, it sees the linebreaks (\n in the fields) as a new row.</p>
  
  <p>Unfortunately i can't give you an example of the real data i work with (it's all personal data), but i can give you an example of how it goes wrong:</p>
  
  <pre><code>Header1,Header2,Header3
  "value1","value2","value 3
  and this is where its going wrong"
  </code></pre>
  
  <p>It's a simple csv file, and when you import it you'll see where it goes wrong. I encapsulate fields with double quotationmarks by default. I also remove leading spaces from values by default.</p>
  
  <p>I've spent at least 2 days on this seemingly simple problem, but for the life of me, i can't figure out how i can fix it. I've seen multiple topics on this same problem, but none of the solutions offered there seem to fix this.</p>