以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  [求助]合并不重复数据问题  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=84643)

--  作者:poiokm26
--  发布时间:2016/5/6 11:46:00
--  [求助]合并不重复数据问题

Dim Book As New XLS.Book("d:\\订单管理表.xls")
Dim Sheet As XLS.Sheet = Book.Sheets(0)
Tables("产品").StopRedraw()
Dim Cols1() As String = {"委托单位","名称","图号","台车定额"}
Dim Cols2() As String = {"客户简称","部件名称","图号","台车定额"}
For dr1 As Integer = 1 To Sheet.Rows.Count -1
    Dim dr2 As DataRow = DataTables("产品").Find("客户简称 = \'" & sheet(dr1,0).Text & "\' And 图号 = \'" & sheet(dr1,2).Text & "\'")
    If dr2 Is Nothing Then \'如果不存在同客户名称和图号的订单
        dr2 =  DataTables("产品").AddNew()
    End If
    For i As Integer = 0 To Cols1.Length - 1
        dr2(Cols2(i)) = sheet(dr1,i).Text
    Next
Next
Tables("产品").ResumeRedraw()


上面的代码是从论坛搜索得来的。不过不够方便,前两行代码可不可以改成

Dim dlg As New OpenFileDialog
dlg.Filter=
"Excel文件|*.xls
If dlg.ShowDialog = DialogResult.Ok Then
Dim Book As New XLS.Book(dlg.FileName)            
Dim Sheet As XLS.Sheet = Book.Sheets(订单)          这里能直接指定表名吗。

这些是帮助之外的知识吧,要从那里才能学到呢,搜百度的又太深奥,大红袍老师,求你可怜一下我这个新人,指点一下学习路线,我从基础学起不怕。

--  作者:大红袍
--  发布时间:2016/5/6 11:53:00
--  
Dim dlg As New OpenFileDialog
dlg.Filter= "Excel文件|*.xls
If dlg.ShowDialog = DialogResult.Ok Then
    Dim Book As New XLS.Book(dlg.FileName)
    Dim Sheet As XLS.Sheet = Book.Sheets("订单")