-- 作者:cxmxjwlmq
-- 发布时间:2020/12/1 10:16:00
-- 网页数据下载标题行出现选择框,无法下载
各位老师:
我在用下面代码进行网页中数据表的下载,并用表头形成临时表的表头,但表头第一列不为空是,可以下载!
Dim web As System.Windows.Forms.WebBrowser = e.Form.controls("webbrowser2").basecontrol Do Until web.ReadyState = 4 AndAlso web.Document.GetElementById("ctl00_C_gv") IsNot Nothing Application.DoEvents Loop Dim elems As object = web.Document.GetElementsByTagName("div") elems = web.Document.GetElementById("ctl00_C_gv").GetElementsByTagName("th") \'ctl00_C_gv Dim dtb As New DataTableBuilder("录入表") For i As Integer = 0 To elems.count-1 dtb.AddDef(elems(i).InnerText,Gettype(String),250) Next dtb.Build() MainTable = Tables("录入表")
DataTables("表B").DataRows.Clear() elems = web.Document.GetElementById("ctl00_C_gv").GetElementsByTagName("tr") Dim ndr As Row For n As Integer = 1 To elems.count - 2 Dim tds = elems(n).getelementsbytagname("td") Dim dr As Row= Tables("表B").AddNew() ndr = Tables("录入表").AddNew() For tn As Integer = 0 To tds.count -1 ndr(tn) = tds(tn).InnerText dr(tn) = tds(tn).innerText Next Next
但有些表表头会有个type=checkbox 选择框,便无法下载!
此主题相关图片如下:微信图片_20201201101400.png
无法下载,提示如下:
此主题相关图片如下:微信图片_20201201101406.png
请教各位老师,怎样修改代码,不管有没有选择框都可以下载!
谢谢!
|