python如何同时使用merge(join)和macro?

时间:2018-11-13 07:00:16

标签: python excel vba pandas

我希望将A.xls文件转换为B.xlsm文件“ sheet2”,并在B.xlsm中执行宏并保存

所以我尝试

writer = win32com.client.Dispatch("Excel.Application") #load to macro
writer = pd.ExcelWriter("B.xlsm", engine = 'openpyxl') #load to write
writer.book = load_workbook("B.xlsm",keep_vba=True) 

df = pd.read_excel("A.xls")
df.to_excel(writer, sheet_name='Sheet1)

writer.Application.Run("addValue")
writer.save()
writer.close()

,但没有错误: AttributeError:“ _ OpenpyxlWriter”对象没有属性“ Application”

这两个任务怎么办?

0 个答案:

没有答案