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 件のコメント

Birdman
Birdman 2018 年 1 月 9 日
What is your code?
Vilvoorde Elabqc
Vilvoorde Elabqc 2018 年 1 月 9 日
編集済み: dpb 2018 年 1 月 9 日
I have a table, called analysisTable, of which the field catNo contains strings. If I write it to an excel file like this
analysisTable=table2cell(analysisTable);
xlswrite(filename,analysisTable(:,1:end-4),'Analysis','A11');
the catNo field is gone. For now, I added this code before the table2cell command:
analysisTable.catNo=cellfun(@char,analysisTable.catNo,'UniformOutput',0)
This seems to solve my problem - although I still think it is weird that I cannot directly write strings to excel.
dpb
dpb 2018 年 1 月 9 日
...I still think it is weird that I cannot directly write strings to excel.
See Answer; documented behavior.

サインインしてコメントする。

 採用された回答

dpb
dpb 2018 年 1 月 9 日
編集済み: dpb 2018 年 1 月 9 日

0 投票

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 件)

質問済み:

2018 年 1 月 9 日

コメント済み:

dpb
2018 年 1 月 9 日

Community Treasure Hunt

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

Start Hunting!

Translated by