求教,如何实现在合并过程中查找是否存在"证件号码"和"管号"相同的行,存在跳过,不存在则增加?下面代码如何修改?
Dim dlg As new OpenFileDialog
dlg.Filter = "excel文件|*.xls;*.xlsx"
dlg.MultiSelect = True
If dlg.ShowDialog = DialogResult.OK Then
For Each f As String In dlg.FileNames
Dim Book As New XLS.Book(f)
Dim Sheet As XLS.Sheet = Book.Sheets(0)
Tables("jcjgsbsj").StopRedraw()
Dim nms() As String = {"姓名","证件号码","核酸检测结果","核酸检测时间","核酸检测机构","管号","行政区名称"}
For n As Integer = 1 To Sheet.Rows.Count -1
Dim bh As String = sheet(n,1).Text
MessageBox.Show("'"& bh &"'")
If bh = "" Then
DataTables("jcjgsbsj").LoadTop = "100"
DataTables("jcjgsbsj").Load
Tables("jcjgsbsj").ResumeRedraw()
Exit For
Else
Dim dr As DataRow = DataTables("jcjgsbsj").Find(" 证件号码 = '" & bh & "'")
If dr Is Nothing Then '如果不存在同批号的订单
dr = DataTables("jcjgsbsj").AddNew()
End If
For m As Integer = 0 To nms.Length - 1
If nms(m) > "" Then
dr(nms(m)) = Sheet(n,m).Value
End If
Next
End If
Next
Tables("jcjgsbsj").ResumeRedraw()
Next
End If
[此贴子已经被作者于2022/3/1 18:09:06编辑过]