将 Excel.Writer 文件保存到新路径时出现问题

Issues with saving an Excel.Writer file to new path

我正在尝试使用 Python 为我的 excel 文档创建一个定时备份系统,因为多个用户将访问它。 我想把文件的路径改成本地目录。

这是代码;

import pandas as pd
import datetime
import numpy
now = datetime.datetime.now()
ct = now.strftime("%Y-%m-%d %H.%M")

table = pd.read_excel(r'Z:\new\Planner_New.xlsx',
                  sheet_name = 'Jan18',                
                  header = 0,
                  index_col = 0,
                  usecols = "A:AY",
                  convert_float = True)

writer = pd.ExcelWriter('Planner' + ct + '.xlsx', engine='xlsxwriter')
table.to_excel(writer, sheet_name = "Jan18")

workbook  = writer.book
worksheet = writer.sheets['Jan18']

format1 = workbook.add_format({'num_format': '0%'})
worksheet.set_column('H:AY', None, format1)

writer.save()
writer.close()

我试过了

outpath = (r'Z:\backup')
writer.save(outpath)
writer.close()

但是回来

TypeError: save() takes 1 positional argument but 2 were given

创建ExcelWriter对象时需要指定保存位置:

writer = pd.ExcelWriter(r'Z:\backup\Planner' + ct + '.xlsx', engine='xlsxwriter')

...

writer.save()
writer.close()