Why do I receive an error (error code: 0x800A03EC) when using XLSWRITE in MATLAB?

103 views (last 30 days)
When I use XLSWRITE I get the following error:
ERROR: ??? Error using ==> xlswrite
Error: Object returned error code: 0x800A03EC

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 30 Apr 2021
Edited: MathWorks Support Team on 30 Apr 2021
There are a number of reasons this error is returned from Microsoft Excel -- the most common is when the user attempts to write data larger than Excel can handle. For example, if you try to write a string longer than 1024 characters to a cell in Excel.
The limits of Microsoft Excel are listed here:
This error is also encountered when a cell that is being exported to Excel has a data field of size 0 x N, where N is an integer.
The following command:
s = size(cell1{1});
will return
s = [0 11]
when the cell contains a 0 x N value.
Another situation that results in this error is when a sheetname containing a colon (:) character is used. For example, the following command returns this error:
xlswrite('test.xls', 'sometext', 'January:February', 'A1');
Finally, the error may be produced when attempting to provide an invalid argument to the fourth 'Range' argument of the XLSWRITE command. XLSWRITE only explicitly supports ranges specified using Excel's 'A1' notation.
If you are iteratively writing to spreadsheet cells in a loop, and using the loop variable in the range argument of XLSWRITE, the NUM2STR function must be used to convert the numeric loop variable to a string for the error not to occur. For example:
for i = 1:10
xlswrite('foo.xls',A,'Sheet1',['A' num2str(i)]);
Another cause for this error is the use of more than 256 colums:
A = [1:257;1:257];
We might also encounter this error when attempting to write to spreadsheets which are protected. Spreadsheets and workbooks can be made protected using the "Protect Sheet/Workbook" option on the "Review" ribbon in the excel sheet.
The limits for Excel 2010 have changed. The XLSWRITE COM interface sometimes will return this error message. As a potential workaround, please consider the script mentioned in the following solution link as an alternative way to write to Excel:
João Araújo
João Araújo on 7 Nov 2017
In my case I got the same error code, but with a diferente issue. I was performing operations in strings to rearrange some data. But everytime you use functions like regexp, or strsplit, the result is a cell, or cell array, with the previous input variable (rearranged) inside. So, by using these 2 functions, my data would follow a structure similar to this cell(cell(str)). For you to be able to use xlswrite, you need to have cell(str). In my case, because I was performing the operations in a for loop, this line of code solved my problem:
The last one was a 1x1 cell with all the data I needed. Keep in mind that there may be intermediate cells, or cell arrays, that you need to call out to extract your info. Hope this helps.

Sign in to comment.

More Answers (0)




Community Treasure Hunt

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

Start Hunting!