How To Iterate Over Worksheets In Workbook, Openpyxl
I've been using the openpyxl module to do some processing on some .xlsx files. I've been trying to figure out how to iterate over sheets in a workbook. I'm not sure if I can get it
Solution 1:
Open the workbook via load_workbook() and iterate over worksheets
:
from openpyxl import load_workbook
wb = load_workbook(r"C:\Excel\LOOKUP_TABLES_edited.xlsx")
for sheet in wb.worksheets:
print sheet
Solution 2:
Here's one if you need active worksheets for your code
for sheet in wb:
ws = wb[sheet]
print('Now in sheet: ' + ws.title)
Post a Comment for "How To Iterate Over Worksheets In Workbook, Openpyxl"