我的代碼無法將數據保存到現有的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