Reading and Writing into an Excel file in qtp

The below mentioned code is developed for Working With Excel Application using QTP

'Creating an Excel object pointing to a Excel File
Set ExcelObj = CreateObject("Excel.Application")

'Opening an excel file - Note:- The excel file needs to be created in the specified dirve for opening
ExcelObj.Workbooks.Open "C:\TestData.xls"

'Pointing to a Excel sheet
Set NewSheet = ExcelObj.Sheets.Item(1)

'Write data to Excel Sheet
For i = 1 to 100

'Assigning the values to excel sheet
NewSheet.Cells(i,1) = "Public QTP Training" & i
NewSheet.Cells(i,2) = "Passed" & i

Next

'Retrieve data from Excel Sheet
sScriptName = NewSheet.Cells(2,1)
sStatus = NewSheet.Cells(2,2)

'Assing the vaues to 3rd row 1st column
NewSheet.Cells(3,1) = sScriptName & sStatus

msgbox(sScriptName)
msgbox(sStatus)

'Save the excel work book
ExcelObj.ActiveWorkbook.Save

'Quit from the excel work book
ExcelObj.Application.Quit

'Destroy the object
Set ExcelObj = Nothing

After the program execution open the excel sheet and see the values that you have entered