【发布时间】:2014-10-16 08:54:05
【问题描述】:
谁能帮帮我!!!!
我有这个函数可以从外部 excel 工作簿调用数据并将值放入被测应用程序中,我需要它逐行遍历 excel 工作表中的所有值
下面是框架的链接以及我正在尝试使用的函数,并且需要它循环遍历 Excel 工作表中的值。请帮忙。
非常感谢
http://www.automationrepository.com/2013/08/designing-hybrid-framework-in-qtp-part-3/
'================================================================================
'Function name - fnFetchDataFromExcelSheet
'Description - This function retrieves the data from the excel sheet based upon the column name
'================================================================================
Function fnFetchDataFromExcelSheet(strColumnName)
Dim sColValue
'Initialize the return the value to "empty" string
fnFetchDataFromExcelSheet = "empty"
'Add a new blank sheet into the QTP data table
'Excel data will be copied into this blank sheet
DataTable.AddSheet("dtDataSheet")
'Import the data from the excel sheet into the QTP data table
DataTable.ImportSheet sExcelWorkbookPath, sSheetName, "dtDataSheet"
'Find the value from the data table
sColValue = DataTable.Value(strColumnName, "dtDataSheet")
'Return the value back to the calling function
fnFetchDataFromExcelSheet = sColValue
'Remove Reference
DataTable.DeleteSheet("dtDataSheet")
End Function
【问题讨论】: