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

39 views (last 30 days)
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 Comment
Kelly Kyriakou
Kelly Kyriakou on 9 Nov 2015
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?

Sign in to comment.

Accepted Answer

Image Analyst
Image Analyst on 10 Nov 2015
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.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!