headings in excel

조회 수: 8 (최근 30일)
M M
M M 2012년 6월 18일
I was wondering if anyone knows how to make column headings using xlswrite function. I tried making a string array that would precede the data, but in the .xls file xlswrite function would expand every character in the string into individual cells, rather than the entire string in one cell to act as the column title. If anyone knows how to have the string, act like a number so that they can be added into the excel in one cell, I would really appreciate it.
- thanks

채택된 답변

M M
M M 2012년 6월 18일
Figured it out for myself so if anyone wants to put column titles here:
C = java_array('java.lang.String',4);
C(1) = java.lang.String('Apple');
C(2) = java.lang.String('Bear');
C(3) = java.lang.String('Cat');
C(4) = java.lang.String('Dog');
T = cell(C)
xlswrite(filenameA,T',1,'A1')

추가 답변 (1개)

Eamonn
Eamonn 2012년 6월 19일
The above solution seems a bit excessive. What if you just did something like this:
T = {'Apple', 'Bear', 'Cat', 'Dog'}; xlswrite(filenameA, T, 1, 'A1');
or if it's just a once off set of titles
xlswrite(filenameA, {'Apple', 'Bear', 'Cat', 'Dog'}, 1, 'A1');
  댓글 수: 1
M M
M M 2012년 6월 19일
That was my initial approach. The problem was that each individual character in the title would end up getting its own cell. So 'Apple' would take five cells, instead of just one to act as the column title. This was the only thing that worked the way I wanted.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by