从excel文件中读取而不丢失数据的最佳方法是什么?Excel 工作表的列格式为 HH:MM:SS,当使用 ADO 读取时,时间格式更改为日期并丢失实际值:
来自excel的样本:
导入网格视图后:
代码:
Try
' Clear the DataGridView and the connection string TextBox
Dim Datatable As New DataTable("Sometable")
' Fill the DataGridView and connection string TextBox
Using connection As New OleDb.OleDbConnection(Super.Excel_GetConnectionString(txtZDCalc_txtPerPath.Text, txtZDCalc_txtPerPath.Tag))
connection.Open()
Using adapter As New OleDb.OleDbDataAdapter("SELECT * FROM [" & cboxZDCalc_Sheet.SelectedItem & "]", connection)
adapter.Fill(Datatable)
End Using
End Using
Super.ZD_GetEmployees(Datatable)
Catch ex As Exception
' Display any errors
MessageBox.Show("[" & ex.[GetType]().Name & "] " & ex.Message & ex.StackTrace)
End Try
为什么进口时间后失去价值?