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:
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
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: