Dim dlg As new OpenFileDialog
dlg.Filter = "EXCEL文件|*.xls"
Tables("订单管理_table1").StopRedraw
If dlg.ShowDialog = DialogResult.OK Then
Dim Book As New XLS.Book(dlg.FileName)
Dim Sheet As XLS.Sheet = Book.Sheets(0)
'注意以下数组中列名称的顺序,必须和Excel表中的列顺序一致
Dim nms() As String = {"商品标题","订单编号","订单状态"}
'注意下面的循环变量从1开始,而不是从0开始,因为Excel表的第一行是标题
Dim dt As DataTable = Tables("订单管理_table1").DataTable
For n As Integer = 1 To Sheet.Rows.Count -1
If dt.Find("订单编号='" & Sheet(n,1).Value & "'") Is Nothing
Dim r As Row = Tables("订单管理_table1").AddNew()
For m As Integer = 0 To nms.Length - 1
r(nms(m)) = Sheet(n,m).Value
Next
End If
Next
Tables("订单管理_table1").ResumeRedraw
End If