Micro Focus QTP (UFT) Forums
How do I get the name of DataTable.Sheet(i)? - 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: How do I get the name of DataTable.Sheet(i)? (/Thread-How-do-I-get-the-name-of-DataTable-Sheet-i)



How do I get the name of DataTable.Sheet(i)? - RandomGrin - 02-16-2013

Hi all,

What I want to do is:

Code:
For i = 1 to DataTable.GetSheetCount
    msgbox DataTable.GETNAMEOFSHEET(i)
next

But there is no method called, GETNAMEOFSHEET...

Is there a way to get the name of a sheet in the DataTable?

The reason I ask is my GetSheetCount is 25 and I have no idea why there are so many! If I could list their names I could figure out where they came from.

Thanks.

PS I am importing .xls files into DataTables just because that is the first way I figured out how to use .xls files.

Should I be doing something like this instead?

Code:
Set xlsApp = CreateObject("Excel.Application")
'Set xlsWorkbook = xlsApp.Workbooks.Open("c:\tests.xls")

Is there any significant difference between importing into DataTables and creating Workbook objects?


RE: How do I get the name of DataTable.Sheet(i)? - newqtp - 02-16-2013

Why don't you try importing sheet and count the sheet in excel.


RE: How do I get the name of DataTable.Sheet(i)? - supputuri - 02-17-2013

Check this below code which will show all the sheet names

Code:
For i = 1 to DataTable.GetSheetCount
msgbox DataTable.GetSheet(i).Name
Next