Foxtable(狐表)用户栏目专家坐堂 → 请问我有一个文件,如何导入


  共有4894人关注过本帖树形打印复制链接

主题:请问我有一个文件,如何导入

帅哥哟,离线,有人找我吗?
大红袍
  11楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2016/7/26 14:31:00 [显示全部帖子]

 删除重复,参考

 

Dim idx As String = "-1,"
Dim idx_temp As String = ""
Dim pdr As DataRow = Nothing
Dim count As Integer = 0
Dim cs As String = "第一列,第二列"
For Each dr As DataRow In DataTables("表A").Select("", cs)
    Dim flag As Boolean = False
    If pdr IsNot Nothing Then
        For Each c As String In cs.split(",")
            If pdr(c).replace(" ","") <> dr(c).replace(" ", "") Then
                flag = True
                Exit For
            End If
        Next
        If flag Then
            If count > 1 Then
                idx &= idx_temp
            End If
            count = 1
            idx_temp = ""
        Else
            count += 1
            idx_temp &= dr("_Identify") & ","
        End If
    Else
        count += 1
    End If
    pdr = dr
Next

If count > 1 Then
    idx &= idx_temp
End If

 

DataTables("表A").DeleteFor("_Identify not In (" & idx.trim(",") & ")")


 回到顶部
帅哥哟,离线,有人找我吗?
大红袍
  12楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2016/7/27 12:18:00 [显示全部帖子]

请去看懂之前的代码。如果要判断,直接find即可,比如

 

If DataTables("某表").Find("某列 = '" & fphm & "'") Is Nothing Then

 

End If


 回到顶部
帅哥哟,离线,有人找我吗?
大红袍
  13楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2016/7/27 14:51:00 [显示全部帖子]

参考代码

 

Dim dlg As new FolderBrowserDialog
If dlg.ShowDialog = DialogResult.Ok Then
    Tables("表a").StopRedraw
    For Each dir As String In FileSys.GetDirectories(dlg.SelectedPath)
        For Each f As String In FileSys.GetFiles(dir)
            If f.EndsWith("_verifysign.log") Then
                If DataTables("表B").Find("文件名 = '" & FileSys.GetName(f) & "'") Is Nothing Then
                    Dim txt As String = FileSys.ReadAllText(f, Encoding.Default)
                    Dim idx As Integer = txt.IndexOf("</business>")
                   
                    Dim s1 As String = txt.SubString(0, idx+11)
                    Dim s2 As String = txt.SubString(idx+12)
                    Dim xmlDoc As New System.XML.XmlDocument
                    xmlDoc.Loadxml(s1)
                   
                    Dim ndList  = xmlDoc.GetElementsByTagName("input")
                   
                   
                    Dim fphm As String
                    Dim xhdwmc As String
                    For i As Integer = 0 To ndList.count - 1
                        If ndList(i).Item("fphm") IsNot Nothing Then fphm = ndList(i).Item("fphm").InnerText
                        If ndList(i).Item("xhdwmc") IsNot Nothing Then xhdwmc = ndList(i).Item("xhdwmc").InnerText
                    Next
                    If fphm <> Nothing Then
                        Dim ndr As DataRow = DataTables("表B").addnew
                        ndr("第二列") = fphm
                        ndr("第三列") = xhdwmc
                        ndr("文件名") = FileSys.GetName(f)
                        ndList = xmlDoc.GetElementsByTagName("fyxm")(0).ChildNodes
                        For i As Integer = 0 To ndList.count - 1
                            Dim spmc As String = ndList(i).Item("spmc").InnerText
                            Dim se As String = ndList(i).Item("se").InnerText
                            Dim dw As String = ndList(i).Item("dw").InnerText
                            Dim spsl As String = ndList(i).Item("spsl").InnerText
                            Dim dj As String = ndList(i).Item("dj").InnerText
                            Dim je As String = ndList(i).Item("je").InnerText
                            Dim r As Row = Tables("表A").AddNew
                            r("第一列") = fphm
                            r("第二列") = xhdwmc
                            r("第三列") =spmc
                            r("第四列") =spsl
                            r("第五列") = dw
                            r("第六列") = se
                            r("第七列") = dj
                            r("第八列") = je
                           
                        Next
                    End If
                End If
            End If
        Next
    Next
    Tables("表a").ResumeRedraw
End If


 回到顶部
总数 14 上一页 1 2