hello guys i got question about how to get rid of time at the back of date when exporting data list in datagridview using vb.net
here picture
this is date in datagridview which is no time at all
but after exporting the data become datetime..same goes to export into pdf..still have time..
Private Sub tsbtnExcel_Click(sender As Object, e As EventArgs) Handles tsbtnExcel.Click
With SaveFileDialog1
End With
If SaveFileDialog1.ShowDialog() = DialogResult.OK Then
Dim filename As String
filename = SaveFileDialog1.FileName
Dim xlApp As Microsoft.Office.Interop.Excel.Application
Dim xlWorkBook As Microsoft.Office.Interop.Excel.Workbook
Dim xlWorkSheet As Microsoft.Office.Interop.Excel.Worksheet
Dim misValue As Object = System.Reflection.Missing.Value
xlApp = New Microsoft.Office.Interop.Excel.Application
xlWorkBook = xlApp.Workbooks.Add(misValue)
xlWorkSheet = xlWorkBook.Sheets("sheet1")
'Export Header Names Start
Dim columnsCount As Integer = DataGridView1.Columns.Count
For k As Integer = 1 To columnsCount
xlWorkSheet.Cells(1, k) = DataGridView1.Columns(k - 1).HeaderText
Next
'Export Header Name End
'Export Each Row Start
Dim i As Integer = 0
For Each row As DataGridViewRow In DataGridView1.Rows
Dim checkselect As Integer = Convert.ToInt16(row.Cells("chkCheck").Value)
If checkselect = 1 Then
For columnIndex As Integer = 1 To columnsCount - 1
xlWorkSheet.Cells(i + 2, columnIndex + 1).Value = row.Cells(columnIndex).Value.ToString
Next
i += 1
End If
Next
'Export Each Row End
xlWorkSheet.SaveAs(filename + ".csv")
xlWorkBook.Close()
xlApp.Quit()
releaseObject(xlApp)
releaseObject(xlWorkBook)
releaseObject(xlWorkSheet)
MessageBox.Show("Export excel file successfully",
"Information",
MessageBoxButtons.OK,
MessageBoxIcon.Information)
Else
MessageBox.Show("Canceled, Export data failed",
"Information",
MessageBoxButtons.OK,
MessageBoxIcon.Information)
End If
End Sub
this is the coding for exporting data into excel..and i use checkbox datagridview so that i can choose which i one to export..so i hope u guy can help me get rid the time when exporting into excel