|
- Sub Test()
- Dim strTemp As String
- Dim objHTML As Object, objWin As Object, objJS As Object
-
- Dim objItems As Object
- Dim lngRows As Long, lngRow As Long
- Dim arrResult As Variant
-
- strTemp = "var gs={Summary:{pages:123,page:1,total:267,DateTime:""2017-03-31 22:00:07""},Item:[{name:""精雕机"",id:""A100001"",code:""307451"",price:252.1,zj:-1.3,stats:1,time:""08:30:00"",total:329849.2},{name:""角磨机"",id:""A100351"",code:""683426"",price:138.05,zj:0.28,stats:1,time:""08:42:03"",total:142197.5}]}"
- Set objHTML = CreateObject("htmlfile")
- Set objWin = objHTML.parentWindow
- objWin.execScript strTemp, "JScript"
-
- lngRows = objWin.eval("gs.Item.length")
- ReDim arrResult(1 To lngRows, 1 To 8)
- For lngRow = 1 To lngRows
- arrResult(lngRow, 1) = objWin.eval("gs.Item[" & lngRow - 1 & "].name")
- arrResult(lngRow, 2) = objWin.eval("gs.Item[" & lngRow - 1 & "].id")
- arrResult(lngRow, 3) = objWin.eval("gs.Item[" & lngRow - 1 & "].code")
- arrResult(lngRow, 4) = objWin.eval("gs.Item[" & lngRow - 1 & "].price")
- arrResult(lngRow, 5) = objWin.eval("gs.Item[" & lngRow - 1 & "].zj")
- arrResult(lngRow, 6) = objWin.eval("gs.Item[" & lngRow - 1 & "].stats")
- arrResult(lngRow, 7) = objWin.eval("gs.Item[" & lngRow - 1 & "].time")
- arrResult(lngRow, 8) = objWin.eval("gs.Item[" & lngRow - 1 & "].total")
- Next
-
- Sheet1.UsedRange.ClearContents
- Sheet1.Range("A1:H1") = Array("name", "id", "code", "price", "zj", "stats", "time", "total")
- Sheet1.Range("A2").Resize(lngRows, 8) = arrResult
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|