openpyxl - Unable to access excel file with openpyxl when it is open but works fine when it is closed

狂风中的少年 提交于 2019-12-11 17:28:54

问题


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.

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.

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?


回答1:


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.)




回答2:


make sure you have write permission in order to create a excel temporary lock file in said directory...




回答3:


I've had this issue with Excel files that are located in synced OneDrive folders. If I copy the file to a unsynced directory, openpyxl no longer has problems reading the .xlsx file while it is open in Excel.



来源:https://stackoverflow.com/questions/45539241/openpyxl-unable-to-access-excel-file-with-openpyxl-when-it-is-open-but-works-f

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!