필터 지우기
필터 지우기

xlswrite It may be locked by another process

조회 수: 34 (최근 30일)
mariem farhat
mariem farhat 2015년 7월 25일
댓글: Image Analyst 2015년 7월 25일
Hello,
I write this code to save information into excel file within a loop function:
Excel = actxserver ('Excel.Application');
xlsfile = 'E:\Thèse\réalisation\F.xlsx' ;
invoke(Excel.Workbooks,'Open',xlsfile);
for ifile = 3:nfiles-1
d = value;
xlswrite(xlsfile, d, 'Translation',strcat('B',num2str(ifile)));
invoke(Excel.ActiveWorkbook,'Save');
end
invoke(Excel.ActiveWorkbook,'Save');
Excel.Quit
Excel.delete
clear Excel
and this code give the following error: It may be locked by another process.
  댓글 수: 1
mariem farhat
mariem farhat 2015년 7월 25일
Ok, I have download xlswrite1 and replace the command xlswrite by xlswrite1.

댓글을 달려면 로그인하십시오.

답변 (2개)

Image Analyst
Image Analyst 2015년 7월 25일
You already have the file open. It's possible that you don't see it because the Excel server might not be visible. Type control-shift-Esc and see if you see Excel in the Process list. If you do, kill that process. Then try again.
  댓글 수: 1
Image Analyst
Image Analyst 2015년 7월 25일
xlswrite() actually launches Excel and tries to open the file. So if you have the file already opened in Excel, even though you launched it via ActiveX, you won't be able to write to it because the ActiveX process has ahold of it. So, like you said, you need to use xlswrite1(), available from the File Exchange, which will use ActiveX to write to it and won't try to open it again.
For others who are interested, I'm attaching my Excel demo that uses ActiveX and xlswrite1.

댓글을 달려면 로그인하십시오.


Amr Hashem
Amr Hashem 2015년 7월 25일
to save in excel sheet
xlswrite('filename.xls',data,1) ; %%where data is the answer you want to save and '1' the sheet number

카테고리

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