以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  导入去重复  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=22619)

--  作者:lpxjw_zyl
--  发布时间:2012/8/19 10:56:00
--  导入去重复
Dim Book As New XLS.Book(ProjectPath & "资料.xls")
Dim Sheet As XLS.Sheet = Book.Sheets(0)
Tables("资料").StopRedraw()
Dim Filter As String
Dim nms() As String = {"类别","品名","规格","单位"}
For n As Integer = 1 To Sheet.Rows.Count - 1
    Filter = ""
    For m As Integer = 0 To nms.Length - 1
        If m > 0 Then
            Filter = Filter & " And "
        End If
        Filter = Filter & nms(m) & " = \'" & sheet(n,m).Value & "\'"
    Next
    If DataTables("资料").Find(Filter) Is Nothing Then
        Dim r As Row = Tables("资料").AddNew()
        For m As Integer = 0 To nms.Length - 1
            r(nms(m)) = Sheet(n,m).Value
        Next
    End If
Next
Tables("资料").ResumeRedraw()

--  作者:hjie_su
--  发布时间:2012/11/9 20:05:00
--  

带有窗口模式?


--  作者:lin_hailun
--  发布时间:2012/11/9 23:08:00
--  
 代码应该没有错,试一下。

sheet(n,m).Value

 改成

sheet(n,m).Value.Trim()