Forum Discussion

teddy77777's avatar
teddy77777
Contributor
14 years ago

How to get sheet names from Excel workbook?

I am looking for a way to read all of the sheet names from an Excel workbook.  Since the ExcelDriver requires a sheet name I am not sure how to do this.  I am using C# script.  Any ideas?



Thanks

1 Reply


  • Hi,





    For a workbook that is already opened, you can do this by using the script below:





        var ExcelObj = Sys.OleObject("Excel.Application");

        for (var i = 1; i <= ExcelObj["Sheets"]["Count"]; i++)    {

            Log["Message"](ExcelObj["Sheets"]["Item"](i).Name);

        }