-- 作者:lidusan
-- 发布时间:2016/1/13 17:51:00
-- [求助]合并表跳过重复数据
帮助上有合并表重复数据跳过的代码如下:
Dim Book As New XLS.Book("e:\\Data\\Ticket_cgbak.xls") Dim Sheet As XLS.Sheet = Book.Sheets(0) Tables("Ticket_cgbak").StopRedraw() \'注意以下数组中列名称的顺序,必须和Excel表中的列顺序一致 Dim nms() As String ={"Dticket_no","Dbarcode","Dcode","Dprice_in","Dprice_in_tax","Dprice_in_max","Dprice_in_tax_max","Dtax","Dnum","Dnum_min","Dnum_max","Dprice","DInclude_num","Dpack","Darea_produce","Dsale_mode","Ddate"} \'注意下面的循环变量从1开始,而不是从0开始,因为Excel表的第一行是标题 For n As Integer = 1 To Sheet.Rows.Count -1 Dim bh As String = sheet(n,0).Text If DataTables("Ticket_cgbak").Find("Dticket_no = \'" & bh & "\'") Is Nothing Then \'如果不存在同编号的订单 Dim r As Row = Tables("Ticket_cgbak").AddNew() For m As Integer = 0 To nms.Length - 1 r(nms(m)) = Sheet(n,m).Value Next End If Next Tables("Ticket_cgbak").ResumeRedraw()
可是我的Dticket_no 列有重复,Dbarcode列也有重复,如果Dticket_no 列+ Dbarcode 列就不会重复,如何设红字代码判断Dticket_no 列+ Dbarcode 列为唯一值判断重复?
求各位大师指点!谢谢! 此主题相关图片如下:订单4.bmp
[此贴子已经被作者于2016/1/13 17:55:28编辑过]
|