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


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

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

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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2014/4/24 18:28:00 [显示全部帖子]

 用下面的代码。

 

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


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")
For i As Integer = 0 To trs.count - 1
    output.show("第" & i & "行")
    Dim tds As Object = trs(i).GetElementsByTagName("td")
    For j As Integer = 0 To tds.count - 1
        output.show("(" & i & "," & j & ")=" & tds(j).InnerText)
    Next
Next


 回到顶部