openpyxl-打开时无法使用openpyxl访问excel文件,但关闭时可以正常工作 [英] openpyxl - Unable to access excel file with openpyxl when it is open but works fine when it is closed
问题描述
我一直在用MAC上的openpyxl制作这个python脚本.我能够打开一个excel工作簿,对其进行修改,保存,保持打开状态并运行脚本.
I've been making this python script with openpyxl on a MAC. I was able to have an open excel workbook, modify something on it, save it, keep it open and run the script.
当我切换到Windows 10时,似乎无法修改,保存,保持打开状态并运行脚本.我不断收到[ERRNO 13]权限被拒绝的错误.
When I switched to windows 10, it seems that I can't modify it, save it, keep it open, and run the script. I keep getting an [ERRNO 13] Permission denied error.
我试图删除正在处理的文件夹上的只读模式,我拥有计算机的所有权限,我明确指定了我的excel工作簿的保存目录.
I tried to remove the read only mode on the folder I'm working on, I have all permissions on the computer, I clearly specified the save directory of my excel workbooks.
关于可能是什么问题的任何想法?
Any idea on what could be the issue?
推荐答案
Windows不允许您在其他程序中修改打开的Excel文件-只有Excel可以修改打开的Excel文件.您必须先关闭文件,然后再使用脚本对其进行修改. (这是有关* nix系统的一件好事.)
Windows does not let you modify open Excel files in another program -- only Excel may modify open Excel files. You must close the file before modifying it with the script. (This is one nice thing about *nix systems.)
这篇关于openpyxl-打开时无法使用openpyxl访问excel文件,但关闭时可以正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!