MATLAB: How to export headers from uitable to excel sheet

excelexportguiheadersuitablexlsxlswrite

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);

Best Answer

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);