How do i rename excel worksheet using xlsxwriter in python. I am using python 2.7 in linux to create excel reports. But cannot find an option to rename the tabs
Rename Excel worksheet using xlsxwriter
Asked Answered
You can set the name of a worksheet while adding it via add_worksheet()
:
worksheet = workbook.add_worksheet('My Custom Name')
Note that you cannot set the name of an existing worksheet:
There is no
set_name()
method. The only safe way to set the worksheet name is via theadd_worksheet()
method.
Thanks !! Perfect. I did search in doc. but could not find this example in the worksheet class. –
Tunis
Here, Simple Solution,
book = xlsxwriter.Workbook('hello.xlsx')
sheet1 = book.add_worksheet("Match")
sheet2 = book.add_worksheet("Not_Match")
Another way without using any modules:
with open('example.xls', 'r') as f1, open('renamed.xls', 'w') as f2:
f2.write(f1.read())
© 2022 - 2024 — McMap. All rights reserved.