Why does xlswrite in MATLAB R2020b fail to create or write to a new .xlsx file even though Excel COM automation works?

I am using MATLAB R2020b Update 8 on Windows with Microsoft Excel installed.
I tested xlswrite with a very small standalone script that tries to create a new .xlsx file and write simple data into it using a full file path. MATLAB does not throw a normal crash, but xlswrite returns status 0, no file is created, and Excel returns this COM error:
Sorry, we couldn't find <file path>. Is it possible it was moved, renamed or deleted?
I also tested actxserver('Excel.Application'), and that works correctly, so MATLAB is able to launch Excel through COM.
So the issue seems to be specifically with xlswrite creating/opening the workbook, not with my larger script.
Has anyone seen this in R2020b? Could this be an Excel/COM configuration issue, permissions issue, or something specific to xlswrite?

1 Comment

It's possible a COM Excel session may have been created and error'ed before leaving a zombie process and the file hanging...open Task Manager and after closing any open Excel files and quitting Excel, kill any remaining Excel processes in the Details view, then retry. This will cause Excel to reload the automation engine.
Although it will create a "File Locked" error, another issue that can occur if a COM session fails is the target file was left open. Check for any hidden files with the "~$" prefix. Again, ensure have saved and closed any open files, then delete those placeholder files; if they exist, Excel thinks the file of that name is already open even if not.
As a general practice if you are messing with COM, open a debug session and do your testing of syntax in it...then if somethig goes wrong you still have access to the Excel process and can continue to test until get the syntax correct and still then close the file (with or without save) and then quit the process and delete/clear the handle. If done from the command line, any error it will crash and you'll have lost access to the COM handle and file object.

Sign in to comment.

Answers (1)

Hi @Soham,
I have understood that you are facing an issue with "xlswrite" function throwing an error. However according to MathWorks documentation the use of "xlsread" and "xlswrite" is no longer recommended for compatibility reasons. For more information on how to replace "xlsread" & "xlswrite" the following documentation links can be referred:
I hope this helps!

Products

Release

R2020b

Tags

Asked:

on 30 Mar 2026

Answered:

on 8 Apr 2026

Community Treasure Hunt

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

Start Hunting!