Forum Discussion

hxiao's avatar
hxiao
Occasional Contributor
9 years ago

How to select Excel sheet in python?

Hi, From https://support.smartbear.com/viewarticle/69443/#_ga=1.128686159.2137448148.1449520310 I have python code to read Excel file:   def ReadDataFromExcel(): Excel = Sys.OleObject["Excel.App...
  • ghuff2's avatar
    ghuff2
    9 years ago

    The Sheets collection has to be accessed using Item just like the Cells collection.

     

    For example, your line of code should change to this:

     

    sheet = Excel.Workbooks.open(file).Sheets.Item["Sheet1"]

    Hope that helps.