执行xlwings函数后无法关闭Excel 2016 [英] I cannot close Excel 2016 after executing a xlwings function

查看:1462
本文介绍了执行xlwings函数后无法关闭Excel 2016的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我执行Xlwings函数时,可以保存并关闭工作簿.但是我无法再关闭Excel 2016. 这是一个已知的问题?我该如何解决?

when I execute a an Xlwings function I can save and close the workbook. But I cannot close Excel 2016 anymore. Is this a known issue? How can I fix this?

推荐答案

这是我的工作方式:

import xlwings as xw
wbPath = [WorkbookPath]
wb = xw.Book(wbPath) 
app = xw.apps.active    
wb.save(wbPath)
#wb.close()

app.quit()

请注意,我注释了wb.close()行.您可以跳过此步骤,而是将应用程序设置为活动的Excel实例,保存工作簿,然后退出该应用程序.

Note that I commented out the line wb.close(). You can skip this step and instead set the app = active Excel instance, save the workbook, and then quit the app.

这篇关于执行xlwings函数后无法关闭Excel 2016的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆