8

I'm able to get the desired sheet by using wb["sheet_name"] method but I want to get the first, or let's say the nth sheet, regardless of the name.

wb = load_workbook(filename = xlsx_dir)   # xlsx_dir is the workbook path

ws = wb["Details"]   # Details is the sheet name
eyllanesc
  • 235,170
  • 19
  • 170
  • 241

2 Answers2

28

You need to use the worksheets property of the workbook object

ws = wb.worksheets[0]
eyllanesc
  • 235,170
  • 19
  • 170
  • 241
wstk
  • 1,040
  • 8
  • 14
-5

you need to use worksheet function sheet_by_name

sheet =  wb.sheet_by_name("Details")
Dk2210
  • 14
  • 5