Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Data Table Query
#1
Solved: 10 Years, 3 Months, 1 Week ago
How to fetch the particular cell data in Global/Local sheet? How to check whether that cell is editable or not? Please give me the VB script statement for this.
Reply
#2
Solved: 10 Years, 3 Months, 1 Week ago
Hi there,
we don't have any pure vbscripting methods to get the value from datasheet as it's a QTP specific feature.
Please find the below code which will get the required out out (if i understood your question correctly)
Code:
msgbox GetDataTableCellValue(1,7,2)
Function GetDataTableCellValue(Sheet,Row,Col)
              Dim iRowNumber
              Dim siSheet
              Dim sColumnName
    iRowNumber = Row
    siSheet= Sheet
    sColumnName = GetParameterNumber(siSheet,Col)
    If  iRowNumber <= DataTable.GetSheet(siSheet).GetRowCount Then
        DataTable.GetSheet(siSheet).SetCurrentRow iRowNumber
        GetDataTableCellValue = DataTable.GetSheet(Sheet).GetParameter(sColumnName)    
    Else
        msgbox "The Row '" & iRowNumber & "' does not exit. Please provide a valid row number.",0+16,"Invalid Row Number"
        ExitTest
    End If
End Function
Function GetParameterNumber(Sheet,sParameterNumber)
    On Error Resume Next
    Set oSheet = DataTable.GetSheet(Sheet)
    If oSheet.GetParameterCount = 0 Then
    'If Err.Number <>0  Then
        msgbox "The sheet '" & Sheet & "' does not exit. Please provide a valid sheet name (or) number.",0+16,"Invalid DataSheet Name"
        Set oSheet = Nothing
        ExitTest
    End If
    If  oSheet.GetParameterCount >= sParameterNumber Then
       For iParNumber = 1 to oSheet.GetParameterCount
                GetParameterNumber = oSheet.GetParameter(sParameterNumber).Name
       Next
       Set oSheet = Nothing
    Else
        msgbox "The Column  '" & sParameterNumber & "' does not exit. Please provide a valid column number.",0+16,"Invalid Column Number"
        ExitTest
    End If
End Function

By default all the cells in the runtime datatable are editable. Use the value method of Datatable to edit the value. Note: you can see the new value in the runtime datatable only.

Let me know if you need any more info.
Thanks,
SUpputuri
Reply
#3
Solved: 10 Years, 3 Months, 1 Week ago
Hi Supputuri,

Thank you for your reply with solution. Can you let me know the below statement we can use to get the data in the datatable.

Code :

Code:
Dim Value
Value = datatable(row,column)
print(Value)
Reply
#4
Solved: 10 Years, 3 Months, 1 Week ago
No, you can not.
But there is a simple way you can do the same.

Code:
Datatable.SetCurrentRow row
Value = datatable(col,sheetnumber)
print Value
But you have to make sure that "Run Only One Iteration" option under File>Test Settings>Run tab. Otherwise, you will get the entire column values.
Thanks,
SUpputuri
Reply
#5
Solved: 10 Years, 3 Months, 1 Week ago
Thank you supputuri, it wil help me a lot.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  data table use uft_usr 1 2,105 06-29-2016, 05:23 PM
Last Post: Ankesh
  Writing to Run time data table Neetha 5 11,661 08-27-2015, 10:18 AM
Last Post: supputuri
  Query regarding "Call" statement anupam4j 1 1,908 09-26-2014, 01:46 PM
Last Post: vinod123
  Retrieving data from web table nsuresh316 1 2,950 03-03-2014, 08:29 AM
Last Post: basanth27
  How to get data from data table in Ascending order dipashri 1 3,449 01-28-2014, 09:54 PM
Last Post: jacosta

Forum Jump:


Users browsing this thread: 1 Guest(s)