更新时间:2023-12-01 08:20:34
如果要向现有电子表格中添加工作表,只需继续并将新工作表添加到文件中,而不是复制load
对象并尝试将新表添加到其中.
If you want to add a sheet to an existing spreadsheet, just go ahead and add the new sheet to the file instead of copying your load
object and trying to add the new sheet to it.
from openpyxl import load_workbook
wb2 = load_workbook('template.xlsx')
wb2.create_sheet('sid1')
wb2.save('template.xlsx')