MATLAB Answers


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

When I use XLSWRITE I get the following error:

 ??? Error using ==> xlswrite
 Error: Object returned error code: 0x800A03EC




1 Answer

Answer by MathWorks Support Team on 4 Apr 2017
Edited by MathWorks Support Team on 4 Apr 2017
 Accepted Answer

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:



Thanks for the answer. I am using 2014a and got this error when I was trying to write a large data set to an excel file. I apparently exceeded the 256 column writing limit for an xls file. But I have found that if you switch to an xlsx file, you can exceed this limit. Hope this helps anyone who is working with large amounts of data.

I have found another situation in which xlswrite gives the Error: Object returned error code: 0x800A03EC: when you try to write in a cell a string like this '="sometext'. The issue is that after the equal sign(=) Excel expects a formula and the text(in my example above 'sometext') starts with quote sign('"') but doesn't have the end quote. This is evaluated by Excel as a wrong formula.

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.