Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Correct syntax for read and load global datatable from Resources tab in QC to QTP
#1
Solved: 10 Years, 8 Months, 4 Weeks ago
Hello,
We are trying important to load global and local datasheet from respurces tab in QC into a particular test in QTP.I am looking for piece of code in QTP to import the datasheet? Can anyone help?
Reply
#2
Solved: 10 Years, 8 Months, 4 Weeks ago
Hi,

U can use this,

Code:
Function ImportDataSheet(strsheet)
   Dim sheet_name
   sheet_name=DataTable.LocalSheet.Name
   Call Import_ressources("Subject\97_RTT Resources","TestData","DataSheet.xls",strsheet,sheet_name)
End Function

Subject\97_RTT Resources---> Path in QC
TestData---> Folder in QC where Data sheet is stored
DataSheet.xls----> .xls file(datasheet)
strsheet---> worksheet within .xls workbook from where u want to import data.
sheet_name----> Datatable in qtp where u want to import the .xls file


Code:
Function Import_ressources (parent_folder, proj_name, src_file, src_sheet, dest_sheet)

Import_ressources = false

Set objTreeManager = QCUtil.TDConnection.TreeManager
Set projNode = objTreeManager.NodeByPath(parent_folder)

'  projNode.Count = nombre de REPs trouvés
For i = 1 to projNode.Count
  '  Le sous_dossier a été trouvé
  If instr (1, projNode.Child(i).Name,  proj_name) > 0 Then
   Set projNode = projNode.Child(i)
   Exit For
  End If
     Next
wait(2)
' Recherche du fichier paramètres (attaché)  
Set res = projNode.Attachments.NewList("")
For Each attach In res
  If Not Instr(1 , attach.FileName , src_file) = 0 Then
   attach.Load True, "C:\"
            datatable.AddSheet (dest_sheet )
   ' REM : 1 --> première feuille dans le fichier XLS
    DataTable.ImportSheet attach.FileName, src_sheet, dest_sheet
   'DataTable.ImportSheet attach.FileName, 1, dest_sheet
   Import_ressources = true
  End If
Next
wait(2)
End Function


Regards,
Sankalp
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Reading Global Sheet's DataTable Value Bhuvana 0 1,468 01-05-2020, 10:03 PM
Last Post: Bhuvana
  Error as Global Not defined while trying to retrieve value from Datatable siddharth1609 0 844 09-11-2019, 02:52 PM
Last Post: siddharth1609
  Load testing in QTP newqtp 4 6,980 01-24-2019, 11:32 AM
Last Post: sonali31
  Want to read the data from excel and set read value in the JavaTable rajeevk7 0 2,165 07-10-2017, 04:20 PM
Last Post: rajeevk7
  On Saving Script in QTP 11 my Global Data Sheet data is removed M Adnan Iftikhar 0 2,047 06-02-2015, 09:19 PM
Last Post: M Adnan Iftikhar

Forum Jump:


Users browsing this thread: 1 Guest(s)