How can I write a cell array containing strings to excel?
3 views (last 30 days)
Show older comments
Hi, I have a cell array containing character arrays, numeric data and strings. The character arrays and numeric data are correctly written to excel, but the strings have disappeared.
3 Comments
dpb
on 9 Jan 2018
...I still think it is weird that I cannot directly write strings to excel.
See Answer; documented behavior.
Accepted Answer
dpb
on 9 Jan 2018
Edited: dpb
on 9 Jan 2018
From the documentation,
...
A — Input matrix
matrix
Input matrix, specified as a two-dimensional numeric or character array, or, if each cell
contains a single element, a cell array.
If A is a cell array containing something other than a scalar numeric or text, then xlswrite
silently leaves the corresponding cell in the spreadsheet empty.
...
Just confirmed with R2016b that XLSWRITE has not been upgraded to handle the native string type; you'll have to cast each cell containing a string to character string to use it.
I'd presume it would be on the "to do" list, but submitting an enhancement request might bring it to the top of the pile sooner...
PS. TMW: The most frustrating part of this is the "silent" part; at least a warning would be helpful...
0 Comments
More Answers (0)
See Also
Categories
Find more on Spreadsheets in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!