Add row name from uitable to excel
3 次查看(过去 30 天)
显示 更早的评论
Hello,
I figured out how to export 'ColumnNames' from uitable to Excel Spreadsheet.
But how would I do the same for 'RowNames'?
Any help will be appreciated.
Thank you!
1 个评论
回答(1 个)
Peng Li
2020-4-2
Better using writetable in this case I think. You can specify WriteRowNames as true.
writetable(yourTable, filename, “WriteRowNames”, 1);
2 个评论
Peng Li
2020-4-3
编辑:Peng Li
2020-4-3
function save1_Callback(hObject, eventdata, handles)
[filename,pathname]= uiputfile('*.xls','Save as');
col=get(handles.table1,'columnname')' ;
data=get(handles.table1,'data');
num=[col;data];
% changes
writetable(handles.table1, filename, 'WriteRowNames', 1);
xlswrite([pathname filename],num);
Adam Danz
2020-4-6
+1, clean and effective approach.
But only these lines are needed and you should use the full path to the file.
function save1_Callback(hObject, eventdata, handles)
[filename,pathname]= uiputfile('*.xls','Save as');
writetable(handles.table1, fullfile(pathname, filename), 'WriteRowNames', 1);
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spreadsheets 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!