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

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by