如何从MATLAB中设置Word文档页面布局为两列



如何从MATLAB中设置Word文档页面布局正常为2列,

File='C:UsersiesDocumentsMATLABtest.docx'; %use full path 
[pth,name,ext]=fileparts(file); 
w=Word(file,true); %create document and make visible
addText(w,'Introduction','Heading 1',2); %create a heading, 2 spaces after 
addText(w,recognizedText); %add some text 
newline(w,6); %6 newlines 
pic=sprintf('%s/fig.png',pth); 
saveAs(w,file);

以上代码将文本保存在普通模式的Word文件中,但我需要两列。

Word函数不是标准的MATLAB函数。如果不提供它从哪里来的细节,就不可能确切地说它的返回值w是什么或者如何与它交互。然而,由于其他非标准函数似乎将其视为Word Document对象,因此我们假设它是其中一个的COM接口。

在这种情况下,可以使用:

将列数设置为两个:
w.ActiveWindow.Selection.Sections.First.PageSetup.TextColumns.SetCount(2)

最新更新