MATLAB Answers

how to close an excel file

210 views (last 30 days)
Hellow everyone . i am using
to open an excel file , after doing some modification, i want to close the excel file in order to overwrite the existing data by
xlswrite('myfile.xlsx', my_modified_data )
but sometimes i forgot to close the file manually in between and MATLAB generates an error . Is there any way to automatically close the excel file(by some command like winclose or something like that) before writing into it . Thank You all .

Accepted Answer

Image Analyst
Image Analyst on 21 Nov 2014
Yes. You can use actxGetRunningServer() to connect to Excel and shut it down.
Image Analyst
Image Analyst on 12 Jul 2017
This will kill Excel:
system('taskkill /F /IM EXCEL.EXE');

Sign in to comment.

More Answers (1)

Artem Smirnov
Artem Smirnov on 19 Jan 2017
Try this:
close all
  1 Comment
Image Analyst
Image Analyst on 19 Jan 2017
And when/if you do, you'll see that close does not shutdown other processes and applications like Excel.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!