How to close Excel-file after writetable()?
48 次查看(过去 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');
4 个评论
Md Bhuyian
2020-6-25
I created an excel file named Comparison.xlsx. How do I only close that excel uding this command?
更多回答(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!