• Home
  • Testing
  • SAP
  • Web
  • Must Learn!
  • Big Data
  • Live Projects
  • Blog

In this tutorial, we will be working with Excel with Micro Focus UFT

Consider we want to import the following Sales.xls

Using Excel with QTP

Once imported into HP UFT, the top row becomes the column header. So structure your data accordingly.

The Syntax to import entire Excel file is


In our case

Datatable.import "D:\Automation\Sales.xls"	

Using Excel with QTP

The Syntax to import a particular sheet is

DataTable.ImportSheet(FileName, SheetSource, SheetDest)

Use the method Getrowcount to get number of rows in the sheet

Datatable.import "D:\Automation\Sales.xls"row = Datatable.getsheet(1).Getrowcount MsgBox row	

Using Excel with QTP

To set the current row to use the method SetCurrentRow

Datatable.import "D:\Automation\Sales.xls"DataTable.SetCurrentRow(1)

' In the code below, 1 is the sheet number

Row1=  Datatable.Value("Year",1)
Row2=  Datatable.Value("Year",1)
MsgBox("Year Row 1 =" & Row1 & "    Year Row 2 =" & Row2  )

Using Excel with QTP

Use the Value method to change data in the imported sheet. Use the Export method to export the Excel

Using Excel with QTP

Using Excel with QTP