Highlighted
Valued Contributor.
Valued Contributor.
1782 views

Global sheet UFT

Jump to solution

Hello everyone,

I am using HPE Unified Functional testing (Version 14.00 build 1775)

I have created a solution Also I am using for Test settings>Resources> Default location(Under test directory).
For my testdata I created path

 

'Set Environment Path
TestPath =environment("TestDir")
environment.value("errorexist")="False"
environment.value("TestPath") =Mid(TestPath,1,Instrrev(Mid(TestPath,1,instrrev(TestPath,"\")-1),"\"))

My sheet I have created in excel contain only 1 sheet called "TestDataDB".

Now when I run  method below

(imports data and loop through it)

Public sub ExcelDataToArr()

TestData=environment.value("TestPath")&"Testdata\DB.xlsx"

Datatable.Importsheet (TestData),"TestDataDB",1
intRowcount=DataTable.GetSheet(1).GetRowCount
For iLoop = 1 To intRowcount
  DataTable.GetSheet(1).SetCurrentRow iLoop
  Username= (DataTable.value("UserName","TestDataDB"))
 
 MsgBox(Username) 
Next

End Sub

 

It doesn't find the sheet called "TestDataDB". It doesn't exists

but if I change the codepart as below.

Username= (DataTable.value("UserName",1))
Msgbox(Username)


then it's alert correct value, then if I alert the sheetname it says suddenly "Global"


How do I change behavior of my UFT to not change my Sheetnames etc?.


I am aware of one solution.
To associate a resource-file to the solution then it's solved....

but the hole point here is to import a excelfile.


Could someone help me out


let me know if there is any doubts.


Thank you in advance

 

Regards

 

 

 

0 Likes
1 Solution

Accepted Solutions
Highlighted
Honored Contributor.
Honored Contributor.

From what I see, 

You are importing sheet from a file to sheet "1"

Datatable.Importsheet (TestData),"TestDataDB",1

This will import the data from "TestDataDB" to "Global", which is by default the sheet with index 1. 

Here the data is getting imported from the specified sheet(External file) to data sheet(index 1). It is not changing the name of the sheet itself. 

Thus, you see the valid message for data and the datasheet as "Global"

If your goal is to import the entire file. Then you should use "Import" not "ImportSheet"

If you want to use ImportSheet, but still get the data into a sheet called "TestDataDB", then you have to first add a sheet with that name and then import data to that sheet. 

Hope this helps. 

GoScriptLESS Create UFT Tests in seconds view demo and more details at scriptlessautomation.com

View solution in original post

0 Likes
3 Replies
Highlighted
Honored Contributor.
Honored Contributor.

From what I see, 

You are importing sheet from a file to sheet "1"

Datatable.Importsheet (TestData),"TestDataDB",1

This will import the data from "TestDataDB" to "Global", which is by default the sheet with index 1. 

Here the data is getting imported from the specified sheet(External file) to data sheet(index 1). It is not changing the name of the sheet itself. 

Thus, you see the valid message for data and the datasheet as "Global"

If your goal is to import the entire file. Then you should use "Import" not "ImportSheet"

If you want to use ImportSheet, but still get the data into a sheet called "TestDataDB", then you have to first add a sheet with that name and then import data to that sheet. 

Hope this helps. 

GoScriptLESS Create UFT Tests in seconds view demo and more details at scriptlessautomation.com

View solution in original post

0 Likes
Highlighted
Valued Contributor.
Valued Contributor.

What if you us Importsheet more than once?

becomes all sheets global then?

0 Likes
Highlighted
Honored Contributor.
Honored Contributor.

If you importsheet more than once and you keep importing data to sheet 1, as in code below, then Yes, you will be overwritting the data in that sheet with new data each time.  

Datatable.Importsheet (TestData),"TestDataDB",1

,  

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.