HTML转表格

Sub ht(Html, Range) s1 = Split(Html, "<tr") rn = UBound(s1) cn = UBound(Split(s1(2), "<td>")) ReDim arr(rn - 1, cn - 1) For ri = 1 To rn s2 = Split(s1(ri), "<td") If UBound(s2) = 0 Then s2 = Split(s1(ri), "<th") For ci = 1 To cn arr(ri - 1, ci - 1) = smid(s2(ci), ">", "<") Next Next Range.Resize(rn, cn) = arr End Sub

Function smid(a, b, c) '截取首次出现文本中间 If InStr(a, b) > 0 Then smid = Right(a, Len(a) - InStr(a, b) - Len(b) + 1) If InStr(smid, c) > 0 Then smid = Left(smid, InStr(smid, c) - 1) End If End If End Function

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

发表于

我来说两句

0 条评论
登录 后参与评论

扫码关注云+社区