Excel write data into a cell not working for below condition
1 次查看(过去 30 天)
显示 更早的评论
Hi all,
I have to write excel cell with data.
If i provide the data though some variable directly then its working but if it is derived from some other variables then its not written into excel file.
Below is the code for which i am getting problem.
A is derived from some other souce.variable but it is present in workspace
C = cellstr(A);
C = C(2:3);
A1 = " Test input cell 1";
A2 =" Test input cell 2";
P{1,1}=A1;
P{1,2}=A2;
c = cellstr(P);
% c = cellstr(C'); %IF USE THIS THEN NO DATA IS WRITTEN INTO EXCEL
C1 = strjoin(c);
b11= cellstr(C1)
b12 = cellstr(' Test input cell 1 Test input cell 2')
filename = 'testdata3.xlsx';
xlswrite(filename,b11)
Please guide on this.
Thanks in advance.
1 个评论
dpb
2019-7-27
编辑:dpb
2019-7-27
We need to know what A actually is...just that it is present doesn't provide sufficient diagnostic data.
NB: From the documentation for XLSWRITE(),
"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."
Also note that while you don't use it in the snippet above, your b12 is a single string in one cell, not two labels as it looks like you probably intended...
b12 = cellstr('Test input cell 1','Test input cell 2');
or, more simply written with "the curlies" as
b12={'Test input cell 1','Test input cell 2'};
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spreadsheets 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!