Discussion:
writing cell with string and numerical matrix to Excel using xlswrite?
(too old to reply)
b***@hotmail.com
2017-11-07 03:15:49 UTC
Permalink
Raw Message
I am trying to write a cell (called FORM) that is a 1x5 cell, that contains string and numerical values. Within the FORM cell it looks like:

'Form Name' 1x10 double 1x10 double 1x10 double 1x10 double

I tried the following:

xlswrite('filename.xls', FORM)%

This did not work...I cannot write the FORM cell to Excel using xlswrite.

I removed the string, 'Form Name' (which leaves me with a 1x4 cell of numerical values), and was able to write the numerical values to Excel using:

xlswrite('filename.xls',FORM)% this works when I remove the first column of string data, leaving the other 4 cells showing as 1x10 double 1x10 double 1x10 double 1x10 double

I have seen there may be ways to use fprintf, but I would rather simply use xlswrite, if possible.

Please help!
dpb
2017-11-07 14:02:14 UTC
Permalink
Raw Message
Post by b***@hotmail.com
'Form Name' 1x10 double 1x10 double 1x10 double 1x10 double
xlswrite('filename.xls', FORM)%
This did not work...I cannot write the FORM cell to Excel using xlswrite.
I removed the string, 'Form Name' (which leaves me with a 1x4 cell
of numerical values), and was able to write the numerical values to Excel
xlswrite('filename.xls',FORM)% this works when I remove the first
column of string data, leaving the other 4 cells showing as 1x10
double1x10 double 1x10 double 1x10 double
I have seen there may be ways to use fprintf, but I would rather
simply use xlswrite, if possible.
help xlswrite

xlswrite(filename,A)example
...
A — Data to write
matrix | cell array
Data to write, specified as a two-dimensional numeric or character
array, or, if each cell contains a single element, a cell array.
...

Reconfigure your A storage pattern as

A=[A{1} num2cell(A{2}) num2cell(A{3})]

and you can use XLSWRITE() per the documentation. Or, use the
Sheet,Range optional arguments to place the cell content where needed
and write the string and the numeric data separately.

FRPRINT() will let you write a csv or other delimited text file but it
will not write a native .xls file in Excel.

--
b***@hotmail.com
2017-11-08 00:21:01 UTC
Permalink
Raw Message
Post by b***@hotmail.com
'Form Name' 1x10 double 1x10 double 1x10 double 1x10 double
xlswrite('filename.xls', FORM)%
This did not work...I cannot write the FORM cell to Excel using xlswrite.
xlswrite('filename.xls',FORM)% this works when I remove the first column of string data, leaving the other 4 cells showing as 1x10 double 1x10 double 1x10 double 1x10 double
I have seen there may be ways to use fprintf, but I would rather simply use xlswrite, if possible.
Please help!
Very clear explanation and it worked! Thank you!

Loading...