Micro Focus QTP (UFT) Forums
How to read the contents of external excel sheet - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: How to read the contents of external excel sheet (/Thread-How-to-read-the-contents-of-external-excel-sheet)

Pages: 1 2


How to read the contents of external excel sheet - qtplearner88 - 05-03-2012

Hi All,

I have one application which requires many user credentials. I am planning to save it in excel sheet and pass those at run time. Please help me in how to write a QTP script which will read username and password columns and pass it to the application.

Looking forward to hear from u all... Thanks!!


Regards
QTP learner


RE: How to read the contents of external excel sheet - sshukla12 - 05-04-2012

Hi,
The easiest way to do is to load the external sheet during run time in ur data table and use data table to insert the username and password for the same.

Let me know in case of any further help.

Regards,
Sankalp


RE: How to read the contents of external excel sheet - qtplearner88 - 05-04-2012

Hi Sankalp,
How to do this with descriptive programming?? I need to learn that too..Pls help..

Regards
QTP learner


RE: How to read the contents of external excel sheet - sshukla12 - 05-04-2012

Hi,

Data table import/export is different from Descriptive programing, if u want to implement DP u can use it in assigning the username and password but for handling external excel file DP is not the correct approach, and to learn DP u can surf through this site only and its an easy and interesting topic.

Let me know if I can help u more.

Regards,
Sankalp


RE: How to read the contents of external excel sheet - qtplearner88 - 05-04-2012

Hi,
Thanks a lot.. sure I will come bak if I am struck anywhere...Thanks Again


RE: How to read the contents of external excel sheet - hammersandnails - 05-22-2012

Sorry its late, but if you'd prefer to do what you originally wanted this might help:

Code:
Public ref

Function LoadfromExcel(filename)
'Loads values from constantxls file into memory
    Dim objExcel
    Dim objWorkbook
    Set ref = CreateObject("Scripting.Dictionary")
    ref.CompareMode = VBTextCompare    
    Set objExcel = CreateObject("Excel.Application")
    Set objWorkbook = objExcel.Workbooks.Open (filename)
    objExcel.Visible = True
    objExcel.Sheets("Constants").Select
    row = 2 'first data row in xls
    
    'fill dictionary with external constants
    While (objExcel.Cells(row,1).Value<>"")
        ref.Add objExcel.Cells(row,1).Value,objExcel.Cells(row,2).Value
        row = row + 1
    Wend  

    objExcel.quit
End Function



RE: How to read the contents of external excel sheet - supputuri - 05-24-2012

Hi Guys,

I know I am late but always it's good habit to use the ADODB connection to read the values from excel files so that we can read the data from different kinds of excel files( .xls, .xlsm, .xlsx.....). Please let me know if you need any further information how to use the ADODB connection and read the data, which will save lot of time and resources.


RE: How to read the contents of external excel sheet - qtplearner88 - 05-24-2012

Hi,

Thnks a lot for ur reply.

Can u explain in detail with an example so that it would be more easy for us to understand?

Thanks
QTPLearner


RE: How to read the contents of external excel sheet - supputuri - 05-25-2012

Hi,

I have posted a function which will provide the required info. Please click on the below link and follow the instructions.

https://www.learnqtp.com/forums/Thread-Generic-Function-to-read-the-data-from-Excel-sql-database-using-ADODB-connection




RE: How to read the contents of external excel sheet - sshukla12 - 05-25-2012

Thnks, Its great. Smile

Regards,
Sankalp