Add row name from uitable to excel

6 ビュー (過去 30 日間)
Miss B
Miss B 2020 年 4 月 2 日
コメント済み: Adam Danz 2020 年 4 月 6 日
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 件のコメント
Aditya Pathak
Aditya Pathak 2020 年 4 月 2 日
Can you please share the codeline in order to receive help?

サインインしてコメントする。

回答 (1 件)

Peng Li
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
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
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 ExchangeDevelop Apps Using App Designer についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by