How to paste matlab table into Excel with headers

30 ビュー (過去 30 日間)
JFz
JFz 2016 年 10 月 5 日
回答済み: David 2025 年 4 月 19 日
Hi,
I have a table in Matlab with many rows. I can copy from Matlab and paste into Excel. But the headers are gone. How to copy the headers into Excel as well? Thanks for any help.
JZ

回答 (3 件)

Patrick Broughton
Patrick Broughton 2022 年 4 月 19 日
Copy and paste your table. Then run header = string(tableName.Properties.VariableNames); and copy and paste the output into your excel book.

Matthew Eicholtz
Matthew Eicholtz 2016 年 10 月 5 日
Try using writetable instead of copy-and-paste.
  1 件のコメント
JFz
JFz 2016 年 10 月 6 日
I see. But That is slower because you have to write it into a file. I would like to just copy it into a spreadsheet that already has some data and I can do some comparison.

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


David
David 2025 年 4 月 19 日
I see this is 3 years old. but I had the same issue, so the solution is to repeat the column names in the first row. then you can easily cut and paste into excel.
% Create table data for selected N_2 values, with headers as first row
data_table = cell(length(plot_indices) + 1, 6); % +1 for header row
% Add headers as first row
data_table{1,1} = 'N_2';
data_table{1,2} = 'P_{shell} (Pa)';
data_table{1,3} = 'P_{cylinder} (Pa)';
data_table{1,4} = 'E_{cylinder} (MeV)';
data_table{1,5} = '% Coulomb';
data_table{1,6} = 'Work (MeV)';

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by