The excel file comprises of a workbook and the workbook then contains sheet(s). We are using an excel sheet which contains it’s first column as the testId or TestName.
1: We pass the TestId or TestName as a string to the function argument.
4: Specify the path name in argument “ExcelPath”. Here we can also extract the path name from a XML file by using the below code.
5: Define the variable to store name of worksheet.
7: Calling the function to check if the file name exists or not.
10: Create the object for Excel
11: Create the object for workbook
12: Create the objects for sheet.
14: Count the number of rows in input sheet and store in variable iRowCount.
15: Count the number of columns in input sheet and store in variable iColumnCount.
17: The outer loop is used for retrieving row which contains the test name or test id same as that was passes in the function
18: for each row, 1st column value is saved in the variable TestName
20: The controls goes into If condition if the TestName retrieved is same as TestId passed. Other wise it is skipped and goes to next row till end of rows.
21: The inner for loop traverses through the columns of required test.
23: each column value is saved in DataArray.
25: Exit the outer for loop after all data has been retrieved.
26: Exit the if statement
29: We need to close the excel object.
33: We should destroy the Objects as not doing so would
35: This statement returns the array “DataArray” to the calling function.