|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
老师能不能帮忙修正下面代码,现在只能提取网页里表格的标题,无法提取下面的数据。
Sub 提取()
On Error Resume Next
Cells.ClearContents
With CreateObject("msxml2.xmlhttp")
.Open "GET", href = "../jqGridExp.do?action=export&rpt=workorders_buffer", False
.send
pageSize = Split(Split(.responseText, ":")(4), ",")(0)
.Open "GET", href = "../jqGridExp.do?action=export&rpt=workorders_buffer", False
.send
strText = "<table>" & Replace(.responseText, "<br/>", "</td>\n<td>") & "</table>"
With CreateObject("htmlfile")
ReDim arrdata(1 To pageSize, 1 To 4)
.write strText
i = 0
For Each tr In .all.tags("table")(0).Rows
i = i + 1
j = 0
For Each td In tr.Cells
j = j + 1
arrdata(i, j) = Replace(td.innertext, " ", "")
Next
Next
End With
Range("b2", "b" & UBound(arrdata) + 1).NumberFormatLocal = "@"
Cells(1, 1).Resize(i, 4).Value = Array("生产任务单号", "物料名称", "当前状态", "金额")
Cells(2, 1).Resize(i, 4).Value = arrdata
End With
End Sub
|
|