Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to read the contents of external excel sheet
#1
Solved: 11 Years, 3 Months, 3 Weeks ago Exclamation 
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
Reply
#2
Solved: 11 Years, 3 Months, 3 Weeks ago
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
Reply
#3
Solved: 11 Years, 3 Months, 3 Weeks ago
Hi Sankalp,
How to do this with descriptive programming?? I need to learn that too..Pls help..

Regards
QTP learner
Reply
#4
Solved: 11 Years, 3 Months, 3 Weeks ago
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
Reply
#5
Solved: 11 Years, 3 Months, 3 Weeks ago
Hi,
Thanks a lot.. sure I will come bak if I am struck anywhere...Thanks Again
Reply
#6
Solved: 11 Years, 3 Months, 3 Weeks ago
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
Reply
#7
Solved: 11 Years, 3 Months, 3 Weeks ago
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.
Thanks,
SUpputuri
Reply
#8
Solved: 11 Years, 3 Months, 3 Weeks ago
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
Reply
#9
Solved: 11 Years, 3 Months, 3 Weeks ago
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-G...connection

Thanks,
SUpputuri
Reply
#10
Solved: 11 Years, 3 Months, 3 Weeks ago
Thnks, Its great. Smile

Regards,
Sankalp
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Trying to create List box in excel sheet at Run time with values yes No JACKSPARROW 0 1,714 01-17-2017, 11:05 AM
Last Post: JACKSPARROW
  Custom sort -Excel Sheet kiran 1 3,868 01-28-2014, 09:23 AM
Last Post: supputuri
  Can we save an exported Excel sheet directly from QTP? Akhila 2 3,466 11-28-2013, 10:30 AM
Last Post: Akhila
  How to identify the object reference to the existing(already opened) Excel sheet yogeesh 1 9,967 09-26-2012, 07:00 PM
Last Post: krr
  programming to use different external file of environment variables bundfromnj 1 3,972 01-19-2012, 05:32 PM
Last Post: SteveS

Forum Jump:


Users browsing this thread: 1 Guest(s)