getting sheet names from openpyxl

后端 未结 3 1002
天命终不由人
天命终不由人 2021-01-31 07:55

I have a moderately large xlsx file (around 14 MB) and OpenOffice hangs trying to open it. I was trying to use openpyxl to read the content, following this tutorial. The code sn

3条回答
  •  执念已碎
    2021-01-31 08:35

    Use the sheetnames property:

    sheetnames

    Returns the list of the names of worksheets in this workbook.

    Names are returned in the worksheets order.

    Type: list of strings

    print (wb.sheetnames)
    

    You can also get worksheet objects from wb.worksheets:

    ws = wb.worksheets[0]
    

提交回复
热议问题