Foxtable(狐表)用户栏目专家坐堂 → 请教:如何获取htm文件中的表格数据到狐表?


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

主题:请教:如何获取htm文件中的表格数据到狐表?

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


加好友 发短信
等级:八尾狐 帖子:1812 积分:12999 威望:0 精华:14 注册:2008/10/11 18:07:00
  发帖心情 Post By:2014/4/24 22:46:00 [显示全部帖子]

向甜甜学习!加上StringBuilder可大大提高效率:

Dim web As New System.Windows.Forms.WebBrowser()
web.Navigate(ProjectPath & "aa.htm" )
Do Until web.ReadyState = 4
    Application.DoEvents
Loop

Dim sb3 As new StringBuilder
Dim s1 As String
Dim elem As object = web.Document.body.GetElementsByTagName("strong")(0)
output.show("表头:" & elem.Innertext)
Dim elems As object = web.Document.body.GetElementsByTagName("table")
Dim trs As object = elems(2).GetElementsByTagName("tr")
Dim tds As Object
For i As Integer = 0 To trs.count - 1
    sb3.AppendLine(vbcrlf )
    tds = trs(i).GetElementsByTagName("td")
    For c As Integer = 0 To tds.count - 1
        s1=tds(c).InnerText
        If s1 IsNot Nothing Then  s1=s1.trim
        If c =0 Then
            sb3.Append(s1)
        Else
            sb3.Append("@"  &  s1)
        End If
    Next
Next
If  sb3.Tostring IsNot Nothing Then
    Output.show(sb3.Tostring)
End If

 回到顶部