How to include header text in a Table when writing to Excel?

8 views (last 30 days)
Hi All
I have to write a table after converting it to array , to Excel . as you can see in the following example taken from this page, if you print the TT you can see the header. but when I converted it to array and tried to write it to Excel ,there was no header
[c,hist,edges,rmm,idx] = rainflow(Z,t);
TT = array2table(c,'VariableNames',{'Count','Range','Mean','Start','End'})
TT=7×5 table
Count Range Mean Start End
_____ _____ ____ _____ ___
0.5 3 -0.5 0 1
0.5 4 -1 1 3
1 4 1 5 6
0.5 8 1 3 4
1 6 1 10 13
0.5 9 0.5 4 8
0.5 10 1 8 15

Accepted Answer

Bhaskar R
Bhaskar R on 26 Dec 2019
In table to array conversion only one type of the data will be displayed, head(string) would skipped.
If you want to write data to excel without converting table to array you can include header
writetable(TT,'output_file.xlsx'); % assumed filename "output_file"
  2 Comments
farzad
farzad on 26 Dec 2019
I get this error :
Error using writetable (line 124)
Unable to write to sheet '' in file 'Ystat.xlsx'. Disable sheet protection, disable workbook's Mark as Final
option, and ensure input does not exceed cell capacity.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!