Copy and Paste Table into Word

43 次查看(过去 30 天)
Mariam NAJI
Mariam NAJI 2020-4-23
回答: BhaTTa 2024-7-17
Hello,
I'm trying to copy and paste into MS Word a table from my code and i couldn't find a way to do it so. I'd like to paste and show in the same way Matlab shows the results on MS word.
I need ur help
Below the code i've been working.
% % % Display names
load_system(gcs);
Blockpaths= find_system(gcs,'Type','Block');
NOM =[];
for i = 1:length(Blockpaths)
b =strsplit(char(Blockpaths(i)),'/');
NOM =[NOM;b(end)];
end
% % % Display Types
open_system(gcs);
blks = find_system(gcs,'Type','block');
TYPE = get_param(blks, 'BlockType');
j = 1;
k = 1;
for i = 1:length(TYPE)
if ( strcmp(TYPE{i},'Inport'))
In{j} = blks{i};
In{j} = strrep(In{j},gcs,'');
j = j + 1;
elseif ( strcmp(TYPE{i}, 'Outport'))
Out{k} = blks{i};
Out{k} = strrep(Out{k},gcs,'');
k = k + 1;
end
end
% % % Create table
CONTENU=cell(length(Blockpaths),1);
t=table(NOM,TYPE,CONTENU);
SRCBLOCK=cell(length(Blockpaths),1);
t=table(NOM,TYPE,CONTENU,SRCBLOCK)
word = actxserver('Word.Application');
word.Visible = true;
wdoc = word.Documents.Add;
Selection = word.Selection;
table = Selection.Tables.Add(Selection.Range,size(t,1),4);
table.Columns.Borders.Enable = 1;

回答(1 个)

BhaTTa
BhaTTa 2024-7-17

类别

Help CenterFile Exchange 中查找有关 Tables 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by