使用xlsxwri重命名Excel工作表

2024-04-19 06:39:14 发布

您现在位置:Python中文网/ 问答频道 /正文

如何在python中使用xlsxwriter重命名excel工作表。我在linux中使用Python2.7创建excel报表。但找不到重命名选项卡的选项


Tags: 报表linux选项excel选项卡重命名xlsxwriter
2条回答

通过^{}添加工作表时,可以设置工作表的名称:

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())

相关问题 更多 >