简体   繁体   中英

python xlrd check if file is already open

Trying to determine if a certain excel file is already open. I have a script that opens up a template excel file and writes data to the file and then saves it as a specific formatted name. Now if the person runs the script again and forgets to close out of the excel file I get errors that stop the program saying cant save the file as it is already open. Is there a way to check if, not only a program is open (excel) but a specific file? That way I can prompt the user to either close the file or save it as another filename.

If the processing time of the input is really small you do not need to detect this before processing the file. You can easily catch the error that you describe with "I get errors that stop the program saying cant save the file as it is already open" and provide a meaningful error message to the user.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM