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


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

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

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


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

高速合并,不是可以合并xml文件吗?

 

用代码也可以,比如代码

 

Dim xmlDoc As New System.XML.XmlDocument
xmlDoc.Load("d:\xml.xml")
Dim ndList  = xmlDoc.GetElementsByTagName("出库明细")

For i As Integer = 0 To ndList.count - 1
    Dim id As String = ndList(i).Item("出库单编号").InnerText
    Dim lb As String = ndList(i).Item("商品类别").InnerText
    output.show(id & " " & lb)
Next


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


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

参考代码

 

Dim dlg As new OpenFileDialog
If dlg.ShowDialog = DialogResult.OK Then
    Dim txt As String = FileSys.ReadAllText(dlg.FileName, 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)
    'output.show(s1)
    'output.show(s2)
   
    Dim xmlDoc As New System.XML.XmlDocument
    xmlDoc.Loadxml(s1)
    Dim ndList  = xmlDoc.GetElementsByTagName("input")
   
    For i As Integer = 0 To ndList.count - 1
        Dim id As String = ndList(i).Item("fphm").InnerText
        output.show(id)
    Next
   
End If


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


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

没看懂你想做什么

 

Dim dlg As new OpenFileDialog
If dlg.ShowDialog = DialogResult.OK Then
    Dim txt As String = FileSys.ReadAllText(dlg.FileName, 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)
    msgbox(s1)
    msgbox(s2)
   
    Dim xmlDoc As New System.XML.XmlDocument
    xmlDoc.Loadxml(s1)
    Dim ndList  = xmlDoc.GetElementsByTagName("input")
   
    For i As Integer = 0 To ndList.count - 1
        Dim fphm As String = ndList(i).Item("fphm").InnerText
        msgbox(fphm)
        Dim xhdwmc As String = ndList(i).Item("xhdwmc").InnerText
        msgbox(xhdwmc)
    Next
   
End If

[此贴子已经被作者于2016/7/25 16:34:47编辑过]

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


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

看懂6楼代码,一个一个获取。

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


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

多条的话,内容是怎样的,文件是怎样的?


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


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

参考代码

 

Dim dlg As new OpenFileDialog
If dlg.ShowDialog = DialogResult.OK Then
    Dim txt As String = FileSys.ReadAllText(dlg.FileName, 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)
    msgbox(s1)
    msgbox(s2)
   
    Dim xmlDoc As New System.XML.XmlDocument
    xmlDoc.Loadxml(s1)
   
    Dim ndList  = xmlDoc.GetElementsByTagName("input")
   
    For i As Integer = 0 To ndList.count - 1
        Dim fphm As String = ndList(i).Item("fphm").InnerText
        msgbox(fphm)
        Dim xhdwmc As String = ndList(i).Item("xhdwmc").InnerText
        msgbox(xhdwmc)
    Next
   
    ndList = xmlDoc.GetElementsByTagName("fyxm")(0).ChildNodes
   
    For i As Integer = 0 To ndList.count - 1
        Dim spmc As String = ndList(i).Item("spmc").InnerText
        msgbox(spmc)
        Dim spsl As String = ndList(i).Item("spsl").InnerText
        msgbox(spsl)
    Next
   
End If


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


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

单个

 

Dim dlg As new OpenFileDialog
If dlg.ShowDialog = DialogResult.OK Then
    Dim txt As String = FileSys.ReadAllText(dlg.FileName, 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
        fphm = ndList(i).Item("fphm").InnerText
        xhdwmc = ndList(i).Item("xhdwmc").InnerText
    Next
   
    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


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


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2016/7/25 23:11: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(".log") 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
                    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
        Next
    Next
    Tables("表a").ResumeRedraw
End If


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


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

测试,没问题,请看15楼。

 

肯定是你有重复的文件导致的。


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


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

For Each s As String In DataTables("表A").GetValues("第一列", "第九列 = '3'")
    DataTables("表A").DeleteFor("第一列 = '" & s & "' and 第九列 = '0'")
Next

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