使用 xlsxwriter 重命名 Excel 工作表
Rename Excel worksheet using xlsxwriter
如何在 python 中使用 xlsxwriter 重命名 excel 工作表。我在 linux 中使用 python 2.7 创建 excel 报告。但是找不到重命名选项卡的选项
您可以在通过 add_worksheet()
添加工作表时设置工作表的名称:
worksheet = workbook.add_worksheet('My Custom Name')
注意 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 the add_worksheet()
method.
不使用任何模块的另一种方式:
with open('example.xls', 'r') as f1, open('renamed.xls', 'w') as f2:
f2.write(f1.read())
如何在 python 中使用 xlsxwriter 重命名 excel 工作表。我在 linux 中使用 python 2.7 创建 excel 报告。但是找不到重命名选项卡的选项
您可以在通过 add_worksheet()
添加工作表时设置工作表的名称:
worksheet = workbook.add_worksheet('My Custom Name')
注意 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.
不使用任何模块的另一种方式:
with open('example.xls', 'r') as f1, open('renamed.xls', 'w') as f2:
f2.write(f1.read())