以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- [求助]如何实现当订单编号重复时,自动跳过 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=111500) |
-- 作者:农村人 -- 发布时间:2017/12/23 9:32:00 -- [求助]如何实现当订单编号重复时,自动跳过 如何实现当订单编号重复时,自动跳过。 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表的第一行是标题 For n As Integer = 1 To Sheet.Rows.Count -1 Dim r As Row = Tables("订单管理_table1").AddNew() For m As Integer = 0 To nms.Length - 1 r(nms(m)) = Sheet(n,m).Value Next Next Tables("订单管理_table1").ResumeRedraw End If
[此贴子已经被作者于2017/12/23 9:32:18编辑过]
|
-- 作者:有点蓝 -- 发布时间:2017/12/23 9:36:00 -- 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
|