Micro Focus QTP (UFT) Forums
Problem in accessing data from excel sheets - 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: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: Problem in accessing data from excel sheets (/Thread-Problem-in-accessing-data-from-excel-sheets)



Problem in accessing data from excel sheets - SNR - 05-06-2009

Dear All,
I have posted this thread earlier also but no repies thatswhy I am posting again with more detailed way so that any one can help me.

The project contains 7 excel files, out of which one is main file and other 6 are sub files. QTP script is written in such a way that first script access main file (contains header-Yes or No and TestCase-Name of Test Cases). If header is Yes corresponding file will open out of 6 sub files and will access the data. One more thing is here Main file contains 6 rows and sub file contains only one row. During script run main file is accessing and even though the header is No it is trying to access the data and is giving error messages, Also it tries to access more than one row in the sub files where as only one row is present.

Please see the code below, data and Screen shots in attachments

Code:
DataTable.Import "C:\SAR\Data\Main.xls"
Rows = DataTable.GetSheet("Global").GetRowCount

For i =1 To Rows
     DataTable.SetCurrentRow(i)
     Header = DataTable.GetSheet("Global").GetParameter
     ("Header").RawValue
     TestCase= DataTable.GetSheet("Global").GetParameter
     ("TestCase").RawValue

     If Header="Yes" Then
        DataTable.Import "C:\SAR\Data\"&TestCase&".xls"
        Rows1 = DataTable.GetSheet("Global").GetRowCount
        For j=1 To Rows1
             DataTable.SetCurrentRow(j)
             FirstName = DataTable.GetSheet("Global").GetParameter
             ("FirstName").RawValue
             MsgBox FirstName
            Next

     Else
        DataTable.Import "C:\SAR\Data\Main.xls"
        DataTable.SetNextRow
  
     End If
Next
Please have look into the code as well as attachments and give me work around to get out of this problem

Thanks in Advance
Narasimha