필터 지우기
필터 지우기

How to export headers from uitable to excel sheet

조회 수: 3 (최근 30일)
Adam Taher
Adam Taher 2015년 7월 15일
댓글: Adam Taher 2015년 7월 15일
Hello, I have a uitable using GUI with 7 columns (number of rows doesn't matter) and I'm able to import data to xls extension with a pushbutton. But I realized that the 7 headers are not imported. Thanks for your help! Here is my code:
data = get(handles.uitable, 'data');
filename = 'something.xls';
xlswrite(filename,data);

채택된 답변

Brendan Hamm
Brendan Hamm 2015년 7월 15일
Well the column names are stored in the 'ColumnName' of the uitable.
data = [get(handles.uitable,'ColumnName');get(handles.uitable, 'data')];
filename = 'something.xls';
xlswrite(filename,data);
  댓글 수: 4
Brendan Hamm
Brendan Hamm 2015년 7월 15일
It may be that your data is all numeric? If this is the case then you need to convert it to a cell array to concatenate:
[get(handles.uitable,'ColumnName')';num2cell(get(handles.uitable,'Data'))]
If not please provide more information.
Adam Taher
Adam Taher 2015년 7월 15일
Finally I tried something like this and it worked. Thanks for you help:
data = get(handles.uitable, 'data');
datax = get(handles.uitable, 'ColumnName');
filename = 'something.xls';
xlswrite(filename,data);
xlswrite(filename,datax,1,'A2:G2');
That way, I don't overwrite my headers.

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

추가 답변 (0개)

카테고리

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