2015-02-23 44 views
0

是否可以在運行時在QTP數據表或Excel表中動態添加新行?它必須是動態的,因爲添加新行取決於輸入數據返回的數據行數。它看起來沒有任何方法可以在數據表或Excel中添加行,所以我不知道如何處理這個問題。根據現有列中的值在QTP中動態添加行

的數據表:6列和當前與4個帳戶號碼現在測試對於爲行,所以它看起來像這樣:

列1,列2,列3,第4欄第5欄第6欄 帳戶1個 帳戶2 帳戶3 帳戶4

的應用:Web應用程序,其具有帳號作爲輸入,並且可返回多行數據。目前,如果帳號號碼返回多行數據,則會覆蓋前一個條目。我需要它在上一行下面創建一個新行(這樣它就不會),並覆蓋上一個條目,並且b。)在下一個帳戶的行上輸入以前的帳戶信息。

這裏是審查的僞代碼:

Dim Rowcount, webrowcnt 
Rowcount=datatable.getsheet"Sheet name".GetRowCount 

For i=1 to Rowcount 
Datatable.GetSheet"Sheet name".SetCurrentRow(i) 
Browser("").Page("").Link("").Click 
Browser("").Page("").WebEdit("").Set DataTable("Row1", dtLocalSheet) 
Browser("").Page("").WebButton("").Click 

webrowcnt=Browser("").Page("").WebTable("").RowCount 

For n=3 to webrowcnt (note: n=3 because the data I need starts on row 3) 
If webrowcnt > 3 Then (note: this is where I want it to create a new row if there is more than 3 rows of data) 
For i=4 to webrowcnt 
some code here to create however many rows of data the account number has. 
Next 
End If 
column1 = Browser("").Page("").WebTable("").GetCellData(n, 1) 
DataTable("column1", dtLocalSheet)=column1 
column2 = Browser("").Page("").WebTable("").GetCellData(n, 2) 
DataTable("column2", dtLocalSheet)=column2 
column3 = Browser("").Page("").WebTable("").GetCellData(n, 3) 
DataTable("column3", dtLocalSheet)=column3 
column4 = Browser("").Page("").WebTable("").GetCellData(n, 4) 
DataTable("column4", dtLocalSheet)=column4 
column5 = Browser("").Page("").WebTable("").GetCellData(n, 5) 
DataTable("column5", dtLocalSheet)=column5 
column6 = Browser("").Page("").WebTable("").GetCellData(n, 6) 
DataTable("column6", dtLocalSheet)=column6 

Browser("").Page("").Link("").click (note: link to return to home page to restart on new account number) 
Next 

回答

0

請與組合嘗試獲得設定的數據表

rowNum=DataTable.GetCurrentRow 
DataTable.setCurrentRow(rowNum+1) 

方法請檢查UFT語法(QTP ),通過關注數據表並按F1。

希望這可以解決您的問題。

0

你可以一直插入值到下一個行和中端插入值導出到外部文件

for n=3 to webrowcnt 
......some code....... 
    If webrowcnt > 3 then 
    DataTable.SetCurrentRow(n) 'now value of n is 4 and so on 
    DataTable.Value("parameter","sheet")="Value" 'fill any data you want 
    ......some code....... 
    end IF 
......some code....... 
next 
相關問題