Forum Discussion

Ravik's avatar
Ravik
Super Contributor
8 years ago

How to get Excel sheet name in TestComplete:Python

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 Python script.  Any ideas?

 

My Code like -

 

ExcelObj = Sys.OleObject["Excel.Application"]

#Delay(1000)

WorkbookObj = ExcelObj.Workbooks.open("path of excel file")

 

--- worksheetobj = WorkbookObj.name('Sheet1')--- Error statement

----worksheetobj = WorkbookObj.get_sheet_by_name('Sheet1') --- tried this also

4 Replies

    • Ravik's avatar
      Ravik
      Super Contributor

      NisHera Thanks for help,

       

      Is there any Python code for same or do we need to import any external python libraries like - import openpyxl

      to perform action.

       

       

      • NisHera's avatar
        NisHera
        Valued Contributor

         I don't thing you need external libraries

        pl check your sample code usually at C:\Users\Public\Documents\TestComplete 12 Samples\Common\MSOffice\Python\Excel_Python