title: How to generate all columns with double quotes in csv export using vb.net
body: <p>I generate csv content type export.</p>
  
  <p>added columns like "A","B","C","D" by</p>
  
  <p>columns = string.format("""{0}"",""{1}"",""{2}""","A","B","C")</p>
  
  <p>stream.writeline(columns);</p>
  
  <p>the csv file was exported but the first column don't having the double quotes. i need double quote with every column. i tried so many ways with in that one of the way is working fine that is 
  columns = string.format(" ""{0}"",""{1}"",""{2}""","A","B","C") -- put space before first column.</p>
  
  <p>but i need result without space.</p>
  
  <p>any one can help to fix this.</p>
  
  <p>Sample Code:</p>
  
  <pre><code>Public Class CSVExporter
      Public Shared Sub WriteToCSV(personList As List(Of Person))
          Dim attachment As String = "attachment; filename=PerosnList.csv"
          HttpContext.Current.Response.Clear()
          HttpContext.Current.Response.ClearHeaders()
          HttpContext.Current.Response.ClearContent()
          HttpContext.Current.Response.AddHeader("content-disposition", attachment)
          HttpContext.Current.Response.ContentType = "text/csv"
          HttpContext.Current.Response.AddHeader("Pragma", "public")
  
          WriteColumnName()
  
          For Each item As Person In personList
              WriteUserInfo(item)
          Next
  
          HttpContext.Current.Response.[End]()
      End Sub
  
      Private Shared Sub WriteUserInfo(item As Person)
          Dim strb As New StringBuilder()
  
  
          AddComma(String.Format("""{0}""", item.Name), strb)
          AddComma(String.Format("""{0} """, item.Family), strb)
          AddComma(String.Format("""{0} """, item.Age.ToString()), strb)
          AddComma(String.Format("""{0:C2}""", item.Salary), strb)
  
  
          HttpContext.Current.Response.Write(strb)
  
          HttpContext.Current.Response.Write(Environment.NewLine)
      End Sub
  
      Private Shared Sub AddComma(item As String, strb As StringBuilder)
          strb.Append(item.Replace(",", " "))
          strb.Append(" ,")
      End Sub
      Private Shared Sub WriteColumnName()
          Dim str As String = """Name"", ""Family"", ""Age"", ""Salary"""
          HttpContext.Current.Response.Write(str)
          HttpContext.Current.Response.Write(Environment.NewLine)
      End Sub
  End Class
  </code></pre>