Excel write data into a cell not working for below condition
1 view (last 30 days)
Show older comments
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 Comment
dpb
on 27 Jul 2019
Edited: dpb
on 27 Jul 2019
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'};
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!