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
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.
Another way without using any modules:
with open('example.xls', 'r') as f1, open('renamed.xls', 'w') as f2:
f2.write(f1.read())
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.