John Yeung
unread,Jul 25, 2013, 10:13:27 PM7/25/13Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to python-excel
Since you're new, I will give you some basics:
Let's say you have a list (any Python list). You can get the index
number from the value:
>>> fruits = ['apple', 'banana', 'pear']
>>> fruits[2]
'pear'
>>> fruits.index('pear')
2
So, applying this to xlrd, get a list of the sheet names using the
sheet_names() method. Get the index number using the index() method.
Assuming you have rb and wb already:
>>> rb_sheet_names = rb.sheet_names()
>>> my_sheet_index = rb_sheet_names.index('my_sheet')
>>> ws = wb.get_sheet(my_sheet_index)
You don't have to be as verbose as that, but I was trying to make it
as easy to follow as I could. If you like, you can combine the above
lines:
>>> ws = wb.get_sheet(rb.sheet_names().index('my_sheet'))
John Y.