希望从EXCEL表中导入数据,其中一列是日期,但EXCEL中显示的日期格式为2015/3/12这样的格式,而不是狐表中默认的3/12/2015
导入的代码为:
Dim dlg As new OpenFileDialog
dlg.Filter = "EXCEL文件|*.xls;*.xlsx"
If dlg.ShowDialog = DialogResult.OK Then
Tables("TempX").StopRedraw
Dim Book As New XLS.Book(dlg.FileName)
Dim Sheet As XLS.Sheet = Book.Sheets(0)
Dim nms() As String = { "RegDate","Title","V" } ‘这里RegDate是日期列,另外两个分别是字符串和数字
For i As Integer = 1 To Sheet.Rows.Count -1
Dim r As DataRow = DataTables("TempX").AddNew()
For m As Integer = 0 To nms.Length - 1
r(nms(m)) = Sheet(i,m).Value
Next
Next
Tables("TempX").ResumeRedraw
end if
但实际执行的时候,会报出这样的错误:
从字符串“2015/7/7”到类型“Double”的转换无效。----意思是不是说EXCEL中的数据会被认为是字符,而无法转换为日期?
如何解决之?