Borrar filtros
Borrar filtros

Add row name from uitable to excel

6 visualizaciones (últimos 30 días)
Miss B
Miss B el 2 de Abr. de 2020
Comentada: Adam Danz el 6 de Abr. de 2020
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 comentario
Aditya Pathak
Aditya Pathak el 2 de Abr. de 2020
Can you please share the codeline in order to receive help?

Iniciar sesión para comentar.

Respuestas (1)

Peng Li
Peng Li el 2 de Abr. de 2020
Better using writetable in this case I think. You can specify WriteRowNames as true.
writetable(yourTable, filename, “WriteRowNames”, 1);
  2 comentarios
Peng Li
Peng Li el 3 de Abr. de 2020
Editada: Peng Li el 3 de Abr. de 2020
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 el 6 de Abr. de 2020
+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);

Iniciar sesión para comentar.

Community Treasure Hunt

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

Start Hunting!

Translated by