cancel
Showing results for 
Search instead for 
Did you mean: 

How to get Excel sheet name in TestComplete:Python

Highlighted
Super Contributor

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 4
Highlighted
Valued Contributor

this may help you........

Highlighted
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.

 

 

Highlighted
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

Highlighted
Super Contributor

@NisHera,

 

I am using TestComplete 11.3, there is no sample for Python 😞

 

Well I have import openpyxl  library and used openpyxl libraries functions.

 

wbo.get_sheet_names()

 

or

workbookobj.get_sheet_by_name("sheet1")

 

New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors