Excel可以从VBScript来控制这样的:
Set xl = CreateObject("Excel.Application")
xl.Visible = True
Set wb = xl.Workbooks.Add
HTML文件可以被解析成DOM文档:
Set doc = CreateObject("Msxml2.DOMDocument.6.0")
doc.async = True
doc.load "C:\path\to\your.html"
使用一个XPath表达来选择人
元素:Set td = doc.selectNodes("//tr/td")
此时td包含文档中所有
元素的集合。你可以这样处理它们:numrows = doc.selectNodes("//tr").Length
numcols = td.Length/numrows
row = 0
For i = 0 To td.Length - 1 Step numcols
If td(i).Text = "Fail" Then
row = row + 1
wb.Sheets(1).Cells(row, 1).Value = CDate(Split(td(i+2).Text)(0))
If InStr(td(i+1).Text, "compliance") > 0 Then
wb.Sheets(1).Cells(row, 2).Value = 1
ElseIf InStr(td(i+1).Text, "Oracletable") > 0 Then
wb.Sheets(1).Cells(row, 3).Value = 1
End If
End If
Next
以上会创建这样一个表:
2/9/2012 1
2/9/2012 1
2/9/2012 1
.
.
.
然后,您可以使用Excel的Consolidate方法来整合数据:
Const xlSum = -4157
wb.Sheets(2).Range("A1").Consolidate _
Array(wb.Sheets(1).Name & "!R1C1:R" & row & "C3"), xlSum