How to rename the sheet name in the spread-sheet using Python?

后端 未结 1 1958
终归单人心
终归单人心 2020-12-30 03:04

Have a scenario where I wanted to change the name of the \"Sheet\" in the spread-sheet.

a. I tried created a spread-sheet saying ss = Workbook(). Think,

相关标签:
1条回答
  • 2020-12-30 03:29

    You can do this by doing the following:

    import openpyxl
    ss=openpyxl.load_workbook("file.xlsx")
    #printing the sheet names
    ss_sheet = ss['Sheet']
    ss_sheet.title = 'Fruit'
    ss.save("file.xlsx")
    

    This works for me. Hope this helps.

    0 讨论(0)
提交回复
热议问题