Dim dlg As New OpenFileDialog dlg.Filter = "Excel文件|*.xls;*.xlsx" If dlg.ShowDialog =DialogResult.OK Then Dim t As Table = Tables("表A") Dim Book As New XLS.Book(dlg.FileName) Dim Sheet As XLS.Sheet = Book.Sheets(0) For n As Integer = 1 To Sheet.Rows.Count -1 Dim cr As Row = Nothing For Each r As Row In t.Rows Dim count As Integer = 0 If r("主机厂") = sheet(n, 0).text Then count += 1 If r("商品车") = sheet(n, 2).text Then count += 1 If r("清单号") = sheet(n, 3).text Then count += 1 If r("底盘号") = sheet(n, 4).text Then count += 1 If count >= 3 Then cr = r Exit For End If Next If cr Is Nothing Then cr = Tables("表B").AddNew() For i As Integer = 0 To sheet.Cols.Count -1 Dim cname As String = sheet(0, i).text If cr.Table.Cols.Contains(cname) Then cr(cname) = sheet(n, i).Text ElseIf cname = "对账金额" Then cr("实际对账金额") = sheet(n, i).Text End If Next Next End If
|