参考下面的代码
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
If DataTables("TempX").DataCols(nms(m)).IsDate Then
r(nms(m)) = Cdate(Sheet(i,m).Value)
ElseIf DataTables("TempX").DataCols(nms(m)).IsNumeric
r(nms(m)) = val(Sheet(i,m).Value)
Else
r(nms(m)) = Sheet(i,m).Value
End If
Next
Next
Tables("TempX").ResumeRedraw
End If