Read more than one file tab

Asked

Viewed 895 times

1

My code goes through all cells in my spreadsheet and returns all the values I need, and in this.xls file there is only one tab.

Now I have a new file to go through and are 8 tabs. I know I need to initialize with:

workbook_r = open_workbook('arquivo.xls', formatting_info=True)
worksheet_r = workbook_r.sheet_by_index(0)

Where on this second line I am setting the tab at 0. How do I go through more than one tab in the entire file? No error, it just doesn’t read the next tab. I couldn’t find any reference in the xlrd library documentation to read more than one tab.

  • Have you tried the sheet_by_name or maybe just sheets()? (that should return you an array of tabs) Note: I also did not find any documentation, only this blog post (in English). I have no experience with this library.

  • Hi, yes. The sheet_by_name is in case I gave prefer by the name of the tab, rather than the position. And only Sheets() not right, because there is no.

1 answer

2


That way it works right for me:

wb = open_workbook('arquivo.xls', formatting_info=True)
for ws in wb.sheets():
    print ws.name, ws.cell_value(1, 1)
  • Hi @sergiopereira, I got it. Thanks for the tip.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.