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.
  1 件のコメント
Kelly Kyriakou
Kelly Kyriakou 2015 年 11 月 10 日
Ok, I will change destination path to path that you suggest me. Thank you very much

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by