Error "xls is not writable. It might be locked by another process" from exe file but not from m file.

25 次查看(过去 30 天)
Hello,
I have written code that opens an excel file, read it and show it to user and then export the data to xls file through xlswrite command. When I run it in matlab it works fine. However, when I compiled it through matlab compiler it opens and shows the data but cannot write the xls file. I opened cmd.exe to see the error and get the following error " nameofexcel.xls is not writable. It might be locked by another process". So, I wrote code if this excel file is open to close it and then write but still it doesn't work. Do you have any suggestions?
Thank you in advance
  1 个评论
Kelly Kyriakou
Kelly Kyriakou 2015-11-9
Actually, I discovered the problem. I hadn't the rights to write a file at the destination folder. I changed the rights and it works. The destination folder was created in program files. Do you have to suggest any destination that will have the rights to write?

请先登录,再进行评论。

采纳的回答

Image Analyst
Image Analyst 2015-11-10
Kelly, Windows does not allow programs (except installers) to write to any files under c:\Program Files. So what I do is to have my m-files on a second internal SSD - no problem writing there. If you want to keep it on your C drive, put the results in your input data folder (if it's not under Program Files) or in your C:\users\Public\Documents folder. You can also make subfolders under there if you want. Every program and user should be allowed to write files to that folder.

更多回答(0 个)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by