Micro Focus QTP (UFT) Forums
Indexing sheets from Global table using column value in Excel - 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 Regular Expressions (https://www.learnqtp.com/forums/Forum-UFT-QTP-Regular-Expressions)
+--- Thread: Indexing sheets from Global table using column value in Excel (/Thread-Indexing-sheets-from-Global-table-using-column-value-in-Excel)



Indexing sheets from Global table using column value in Excel - iluvlabbies - 11-18-2009

Hi - We are pretty new to QTP, but have been working to do some web scripting. For one of the scripts, we call several actions. The developer designed the script to read in the Global sheet for use in each of the local actions. What is problematic is that the action does not seem to be reading the data.

The Global sheet has multiple sheets. The first sheet named "Global" has 3 columns with data for Requestor, Supervisor, and Comments. The action is to read the line, pull the value in the Requestor column, and then use it to read the sheet with the same name in this Excel sheet. So for instance, if the value in the first Global Sheet is "Sam", the action should go to the tab in the same spreadsheet named "Sam" and get the specific data there for processing in a loop. Here is what the code says:

Dim rowcounter, numleavedates, errmsg

'Get the data from the data file for this leave request
Datatable.ImportSheet "..\Leave Request Test Data.xls" , Parameter ("Requestor"), "Leave Request"
'Get the number of rows for this leave request; this script will process up to 6. If the number is blank, it assumes 1 and if the number is > 6 it gives a message and stops.
'It needs this ahead of time because the script needs to know how many rows of data go to each requestor.
numleavedates = DataTable.GetSheet("Leave Request [Leave Request]").GetRowCount

The action is blowing up on the last line that starts with "numleavedates". Is there something wrong with the syntax or is it possible to use a single Global sheet with multiple sheets for use in local actions. Sad

Any help that you might have for us would be SOOOO appreciated! We are pretty much stuck. Thanks, Kathy


RE: Indexing sheets from Global table using column value in Excel - Saket - 11-19-2009

First check if the required sheet is imported into datatable successfully
then try this
Code:
numleavedates = DataTable.GetSheet("Leave Request").GetRowCount

let us know how it goes