Datagrid Export to Csv - Datetime problem

  • Thread starter Thread starter pb1990
  • Start date Start date
P

pb1990

Guest
I'm exporting my datagridview to csv. it works perfectly but I face a problem with dateformat in csv file. I have "dd/mm/yyyy" in datagridview but I get "dd/mm/yyyy hh:mm:ss". I'm running the exporting procedure with this code:

Private Sub Last10ExportCSVButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Last10ExportCSVButton.Click
Try
Dim StrExport As String = ""
For Each C As DataGridViewColumn In ProdottiDataGridView.Columns
StrExport &= """" & C.HeaderText & ""","
Next
StrExport = StrExport.Substring(0, StrExport.Length - 1)
StrExport &= Environment.NewLine
For Each R As DataGridViewRow In ProdottiDataGridView.Rows
For Each C As DataGridViewCell In R.Cells
If Not C.Value Is Nothing Then
StrExport &= """" & C.Value.ToString & ""","
Else
StrExport &= """" & "" & ""","
End If

Next
StrExport = StrExport.Substring(0, StrExport.Length - 1)
StrExport &= Environment.NewLine
Next
Dim tw As IO.TextWriter = New IO.StreamWriter("Test1.CSV")
tw.Write(StrExport)
tw.Close()
Catch ex As System.Exception
System.Windows.Forms.MessageBox.Show(ex.Message)
End Try
End Sub


What can I do to solve my problem?


Thank you.

Continue reading...
 
Back
Top