Export column name along with data in excel file in GUI

1 visualización (últimos 30 días)
Mario
Mario el 7 de Ag. de 2017
Comentada: Mario el 8 de Ag. de 2017
Helo,
I am builing a GUI and inside my GUI I have a table data named Results_table that contains a numerical values columnwise (n,1) stored in different columns with their respective names.
Now, I was able to export these values from the table Results_table in an excel file, but I could not find a solution to export the column names too with those values.
My code for this section is:
M=get(handles.Results_table, 'Data'); % I get values from table Results_table but it only exports values, and not their respective column names
FileName = uiputfile('*.xls','Save as');
xlswrite(FileName, M); %I save stored data in M
Is there a solution to this problem? How can I export column names that are associated with those numerical values inside table Results_table?
Thanks!

Respuesta aceptada

Jan
Jan el 7 de Ag. de 2017
M = get(handles.Results_table, 'Data');
Head = get(handles.Results_table, 'ColumnName');
Data = cat(1, Head, num2cell(M));
xlswrite(FileName, Data)
  5 comentarios
Mario
Mario el 8 de Ag. de 2017
I just used this line of code for retreiving Column names in another function (for further work), and saw that this code:
Head = get(handles.Results_table, 'ColumnName');
gives me the appropriate ColumnNames that matches the data in M, so now I am not sure where the error is regarding using cat.
Mario
Mario el 8 de Ag. de 2017
I figured it out.
For some reason, the ColumnName that I extracted from handles.Results_table and stored it in Head had column names in a vertical order. That is why cat was giving me error, so by using:
Head1=transpose(Head)
and place them horizontaly, I was able to solve the problem.
Thanks!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by