我在 Matlab 中的代码,经过计算,以 word 打印出结果。我为此使用 writetoword.m,我的结果主要是表格。我需要帮助来对齐这些表格。
FileSpec = fullfile(CurDir,[WordFileName,'.pdf']);
[ActXWord,WordHandle]=StartWord(FileSpec);
WordCreateTable(ActXWord,NoRows,NoCols,readings,6);
function WordCreateTable(actx_word_p,nr_rows_p,nr_cols_p,data_cell_p,enter_p)
if(enter_p(1))
actx_word_p.Selection.ParagraphFormat.Alignment=1;
actx_word_p.Selection.TypeParagraph;
end
actx_word_p.Selection.ParagraphFormat.Alignment=1;
actx_word_p.ActiveDocument.Tables.Add(actx_word_p.Selection.Range,nr_rows_p,nr_cols_p,2,1);
for r=1:nr_rows_p
for c=1:nr_cols_p
actx_word_p.Selection.ParagraphFormat.Alignment=1;
WordText(actx_word_p,data_cell_p{r,c},'Normal',[0,0]);
if(r*c==nr_rows_p*nr_cols_p)
actx_word_p.Selection.MoveDown;
else
actx_word_p.Selection.MoveRight;
end
end
end
end
function WordText(actx_word_p,text_p,style_p,enters_p,color_p)
if(enters_p(1))
actx_word_p.Selection.TypeParagraph;
end
actx_word_p.Selection.Style = style_p;
if(nargin == 5)
actx_word_p.Selection.Font.Color=color_p;
end
actx_word_p.Selection.TypeText(text_p);
actx_word_p.Selection.Font.Color='wdColorAutomatic';
for k=1:enters_p(2)
actx_word_p.Selection.TypeParagraph;
end
set(actx_word_p.Selection.ParagraphFormat,'Alignment',1);
end
我想在一张纸上打印所有表格,我需要并排的表格。使用上面的代码,它总是从新行开始。我怎样才能做到这一点?