title: How can I export the datagridview to .csv without headers?
body: <p>My csv file is like <a href="https://i.stack.imgur.com/g0JTz.png" rel="nofollow noreferrer">this</a>
  There is no blank spaces or whatsoever.</p>
  
  <p>The problem as you can see is that I do not know how to export my datagridview as .csv excluding column headers.</p>
  
  <p>This is how I have done my export code:</p>
  
  <pre><code>    Private Sub IncomeToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles IncomeToolStripMenuItem.Click
      Dim saveFileDialog1 As New SaveFileDialog()
  
      saveFileDialog1.Filter = "CSV|*.csv"
      saveFileDialog1.RestoreDirectory = True
  
      If saveFileDialog1.ShowDialog() = DialogResult.OK Then
          Dim incomefile As String = String.Empty
  
          For Each column As DataGridViewColumn In Expense.Columns
              incomefile = incomefile &amp; column.HeaderText &amp; ","
          Next
  
          incomefile = incomefile.TrimEnd(",")
          incomefile = incomefile &amp; vbCr &amp; vbLf
  
          For Each row As DataGridViewRow In Expense.Rows
              For Each cell As DataGridViewCell In row.Cells
                  incomefile = incomefile &amp; cell.FormattedValue.replace(",", "") &amp; ","
              Next
              incomefile = incomefile.TrimEnd(",")
              incomefile = incomefile &amp; vbCr &amp; vbLf
          Next
          System.IO.File.WriteAllText(saveFileDialog1.FileName, incomefile)
      End If
  
      Dim msg1 = "Export Successful"
      Dim title = "Excel Export"
      MsgBox(msg1, , title)
  End Sub
  </code></pre>
  
  <p>Please advise me. Some others mentioned that I'd better off use datatable to export it, but since I started to learn computer programming 43 hours ago, I have no clue on how to declare the data i have put in my datagridview and export it as csv file.</p>