Friday, 9 August 2013

How to Export HP QTP Result in to Excel Sheet Using Script

HP QTP provides functions to add the results to the Excel File instead in the QTP Results Window.
We will be using a separate Sheet by name “Results” in which the Results of the Test will be appended.
There are 2 functions
1) initOutExcel(sTablePath)
Description: This function is to initialize a particular Excel Where you want to update the Results of the QTP Tests.
2) WriteResults(sTablePath,sStatus,sFunctionality,sDescription)
Description: This function appends the Result of a Test to the end of the existing results.
Function Code is as follows :
//Function initOutExcel code
Function initOutExcel(sTablePath)
Datatable.addSheet “Results”
Datatable.importSheet sTablePath, “Results”,”Results”
iParamCount = Datatable.getSheet(”Results”).getParameterCount
if iParamCount = 0 Then
Datatable.getSheet(”Results”).addParameter “S.No”,”"
Datatable.getSheet(”Results”).addParameter “Status”,”"
Datatable.getSheet(”Results”).addParameter “Functionality”,”"
Datatable.getSheet(”Results”).addParameter “Description”,”"
End If
Datatable.ExportSheet sTablePath,”Results”
End Function
//Function WriteResults code
Function WriteResults(sTablePath,sStatus,sFunctionality,sDescrip)
Datatable.addSheet “Results”
Datatable.importSheet sTablePath, “Results”,”Results”
iRowCount = Datatable.getSheet(”Results”).getRowCount
Datatable.getSheet(”Results”).setCurrentRow(iRowCount+1)
Datatable(”S.No”,”Results”) = iRowCount+1
Datatable(”Status”,”Results”) = sStatus
Datatable(”Description”,”Results”) = sDescrip
Datatable(”Functionality”,”Results”) = sFunctionality
Datatable.ExportSheet sTablePath,”Results”
End Function

No comments:

Post a Comment