Reputation: 43
I've googled and searched this question for a while with no success. Is it possible to open a worksheet in an Excel workbook with openpyxl by using its index? For example, I want to insert a photo into the second worksheet for every workbook in my folder. If the sheet name is variable, could I open the sheet using its index? Any help would be greatly appreciated, thanks!
Upvotes: 4
Views: 13179
Reputation: 417
Actually, using index to open a sheet is easy. Check the python code example given below:
from openpyxl import load_workbook
workbook = load_workbook("your path")
sheet = workbook.worksheets[1]
Upvotes: 13