Python openpyxl switch between spreadsheets in one workbook -
i can see sheet names when use
wb.get_sheet_names()
now rename sheets 1 after other numbers i.e first sheet 1, second sheet 2 , on.
loop through each sheet , set title whatever want.
from openpyxl import load_workbook wb = load_workbook('test.xlsx') sheets = wb.get_sheet_names() counter = 0 sheet in sheets: ss_sheet = wb.get_sheet_by_name(sheet) ss_sheet.title = str(counter) wb.save("file.xlsx") counter+= 1
Comments
Post a Comment