Dim Book As New XLS.Book("F:\H\问题测试\1111.xlsx")
Dim Sheet As XLS.Sheet = Book.Sheets(0)
Dim nms() As String = {"姓名","住址","年龄"}
Dim s1 As new List(of String)
s1.AddRange(nms)
Dim dict As new Dictionary(of String,Integer)
For m As Integer = 0 To sheet.Cols.count -1
If s1.Contains(sheet(0,m).value) Then
dict.add(sheet(0,m).value,m)
End If
Next
If dict.Count <> nms.Length Then
msgbox("电子表格文件不符要求")
Return
End If
Tables("表A").StopRedraw()
For n As Integer = 1 To Sheet.Rows.Count -1
Dim bh As String = sheet(n,dict("姓名")).Text
Dim dr As DataRow = DataTables("表A").Find("姓名 = '" & bh & "'")
If dr Is Nothing Then '如果不存在同编号的订单
dr = DataTables("表A").AddNew()
End If
For Each key As String In dict.Keys
dr(key) = Sheet(n,dict(key)).Value
Next
Next
Tables("表A").ResumeRedraw()