MATLAB Answers

xlswrite error in MATLAB R2018b

48 views (last 30 days)
Rene Labounek
Rene Labounek on 6 May 2019
Commented: Walter Roberson on 6 May 2019
I have an issue with exporting result to xlsx file at MATLAB R2018b installed at Ubuntu 18.04.2 LTS. I have tried a code directly from the MATLAB help and I am getting the same error:
filename = 'testdata.xlsx';
A = {'Time','Temperature'; 12,98; 13,99; 14,97};
sheet = 2;
xlRange = 'E1';
xlswrite(filename,A,sheet,xlRange)
The error is:
Warning: Unable to write to Excel format, attempting to write file to csv format. To write to an Excel file, convert your data to a
table and use writetable.
> In xlswrite (line 179)
Error using xlswrite (line 192)
An error occurred on data export in CSV format.
Caused by:
Error using dlmwrite (line 104)
The input cell array cannot be converted to a matrix.
Any idea how to fix it?
Kind regards and thanks,
Rene

Answers (1)

Jan
Jan on 6 May 2019
What about the hint given in the error message:
To write to an Excel file, convert your data to a table and use writetable.
  1 Comment
Walter Roberson
Walter Roberson on 6 May 2019
To expand a bit:
xlswrite() is only capable of writing .csv files on Mac and Linux, and on MS Windows systems that do not have Excel installed. MATLAB for Mac and Linux do not provide the interface calls that are used to talk to Excel directly, and it would not matter if they did have it because the interface used is not compiled into Excel for Mac (and Excel does not exist for Linux.)
However, starting R2013b, writetable() has been able to create .xls and .xlsx .

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!