Student Mode Code Display

Welcome to the Fraternity!

Commenting has been enabled. You can comment on all the Code Items now.

DataTable Importing External Excel File in to Data Table and Iterating it

Add This Code to My Favourite List
Enter Email

Contributed By IT Prof
Date 2016-03-12 07:25:52

Tutorial: itprof_tut
'Description: Example of Importing External Excel File in to Data Table and Iterating it
'Author: Akash
'Company: IT Professional Academy

Dim sFilePath, sSrcSheetName, sSrcTargetSheet
sFilePath = "C:\QTPStuff\QTPTrainingCode\DataSheet\DataSheet.xls"
sSrcSheetName = "SmokeTest"
sSrcTargetSheet = "SmokeTest"

'Add New Sheet- Add New Sheet before Deleting last Sheet. There has to be at least one sheet available

'Delete Unwanted Sheet

'Import External Sheet in SmokeTest Sheet
DataTable.ImportSheet sFilePath,sSrcSheetName, sSrcTargetSheet

'Get Row Count
sRowCount =  DataTable.GetSheet("SmokeTest").GetRowCount

'Looping on the Excel Sheet
For i=1 to sRowCount
	'Reading values form Current Row
	sFncName = DataTable.Value("FunctionName",sSrcTargetSheet)
	sRunFlag = DataTable.Value("RunFlag",sSrcTargetSheet)
	sArg1 = DataTable.Value("Arg1",sSrcTargetSheet)
	sArg2 = DataTable.Value("Arg2",sSrcTargetSheet)
	sArg3 = DataTable.Value("Arg3",sSrcTargetSheet)
	sArg4 = DataTable.Value("Arg4",sSrcTargetSheet)
	sArg5 = DataTable.Value("Arg5",sSrcTargetSheet)
	'Checking if Run Flag is Set
	If sRunFlag = "TRUE" Then
		Select Case sFncName
			Case "InvokeApp"
				Call InvokeApp(sArg1)
			Case "Login"
				Call Login(sArg1,sArg2)
			Case "NavigateToPage"
				Call NavigateToPage(sArg1)
		End Select
		DataTable.Value("Result",sSrcTargetSheet) = "Executed"
		Reporter.ReportEvent micDone,"KW Skipped", sFncName
		DataTable.Value("Result",sSrcTargetSheet) = "Not Executed"
	End If

	'Setting the next row


Download Above Code


Add your comments...
Name : *      
Email : *      
The content of this field will be kept private and will not be shown publicly

Your Comment/Answer *

Enter the text present in this box : *