How to close Excel-file after writetable()?
    조회 수: 18 (최근 30일)
  
       이전 댓글 표시
    
I want to use writetable() for an Excel-file in a for-loop. But at the second loop it stops with an error, because the first file is still open and there is no permission. Before I'd open a new folder for the new excel-file, but it doesn't work in this way now, because the file is still open.
댓글 수: 0
채택된 답변
  Image Analyst
      
      
 2016년 10월 10일
        
      편집: Image Analyst
      
      
 2016년 10월 10일
  
      I got this from the Mathworks directly:
You can use the following SYSTEM command via MATLAB to kill the process:
>>   system('taskkill /F /IM EXCEL.EXE');
댓글 수: 5
  Md Bhuyian
 2020년 6월 25일
				I created an excel file named Comparison.xlsx. How do I only close that excel uding this command?
  Martin
 2025년 1월 15일
				추가 답변 (2개)
  Walter Roberson
      
      
 2016년 10월 11일
        Use table2cell() to create a cell array, and use xlswrite1() from the File Exchange, as that gives you an interface in which you have specific control over closing the spreadsheet.
댓글 수: 5
  Image Analyst
      
      
 2020년 6월 26일
				You must have changed the file.  There is no workbooks variable in the attached function.  You forgot to give the complete error which included the line of code so I don't know how you modified the function.  Nevertheless, that demo is from 4 years ago and I have a new one, which I'm attaching here.  And I just ran this so I know it works.
Plus I attached a second, separate demo showing how to put a formula into an Excel cell.
참고 항목
카테고리
				Help Center 및 File Exchange에서 Spreadsheets에 대해 자세히 알아보기
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!




