wrting a cell array of strings to excel

1 view (last 30 days)
A K
A K on 11 Apr 2011
This is more of an Excel question than Matlab.
H1 H2 H3 H4 H5 20080 34611 ABC 123 10,21,30 20080 34612 DEF 567 1,2,5
I have a cell array called output displayed above which I write to excell from matlab via
xlswrite('opfile.xlsx', output, 'outsheetname', 'A1')
But Excel interprets the last column (an array of strings) incorrectly as it has both commas and integers and the resulting column is incorrectly displayed - even when the Excel cells are formatted as text. (The other columns are displayed correctly)
When I write the last column of output to a text file via
temp = [ output(:,5)'] ifp = fopen('outfile.txt', 'w') fprintf(ifp, '%s\n', temp{:}) fclose(ifp)
the text is written perfectly.
any ideas? Thanks

Answers (1)

Robert Cumming
Robert Cumming on 11 Apr 2011
You could also investigate
dlmwrite
where you can specify the delimiter for importing into excel.

Community Treasure Hunt

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

Start Hunting!