我的代码无法将数据保存到现有的excel文件中。我可以从它是从一个网表将数据复制到Excel工作表本地窗口看到,但无法保存details.Could请您正确的,如果我缺少这里有什么问题无法将webtable内容保存到qtp中的excel文件中
path = "D:\Demo\TestData\Shopping_Cart.xls"
set xl= CreateObject("excel.application")
xl.workbooks.open(path)
set nsheet=xl.sheets.item(1)
Set BrwsrCheckOut= Browser("name:=Checkout","title:=Checkout - Internet Explorer").page("title:=Checkout","name:=.*")
Set DesPrdChcKOut = Description.Create
DesPrdChcKOut("html tag").value = "TABLE"
DesPrdChcKOut("column names").value = "Product Name;Model;Quantity;Price;Total"
For IteratorRow = 1 To 2
'BrwsrCheckOut.WebTable(DesPrdChcKOut).RowCount Step 1
For IteratorCol = 1 To 3
'BrwsrCheckOut.WebTable(DesPrdChcKOut).ColumnCount(1) Step 1
val = BrwsrCheckOut.WebTable(DesPrdChcKOut).GetCellData(IteratorRow, IteratorCol)
Next
Next
'xl.Activeworkbook.saveAs "D:\Demo\TestData\Shopping_Cart.xls"
xl.Activeworkbook.save
nsheet.SaveAs("D:\Demo\TestData\Shopping_Cart.xls")
xl.ActiveWorkbook.Close
Set xl = nothing
Set nsheet = nothing
您是否考虑过将excel文件导入为数据表格,使用可用的'Datatable'函数在UFT内更新它,然后将其导出?无论如何,要比创建excel对象简单得多... – Dave