wordreport
WORDREPORT creates or opens an existing Microsoft Office Word report and provides helper functions to add some content: text, figures, Simulink models, Stateflow charts and much more. It also helps in adding or updating the table of contents, in setting page numbering or in finding text. Actually, it is possible to mimic almost everything you can do manually. Just record a macro in Word and analyze the generated VBA code to find out how to use the ActiveX technology.
Example: create a new document called 'Foo.doc' and add some content (headings, figures, page breaks, page numbers, table of contents)
reportFilename = fullfile(pwd,'foo.doc');
wr = wordreport(reportFilename);
%---
wr.setstyle('Heading 1');
wr.addtext('TOC', [1 1]); line break before and after text
wr.createtoc(1, 3);
wr.addpagebreak();
%---
wr.setstyle('Heading 1');
wr.addtext('MATLAB data', [1 1]); line break before and after text
%---
wr.setstyle('Heading 2');
wr.addtext('Sample table', [0 1]); line break after text
dataCell = { ...
'Test 1', num2str(0.3) , 'OK'; ...
'Test 2', num2str(1.8) , 'KO'};
[nbRows, nbCols] = size(dataCell);
wr.addtable(nbRows, nbCols, dataCell, [1 1]); line break before table
%---
wr.setstyle('Heading 2');
wr.addtext('Sample figure', [0 1]); line break after text
figure; plot(1:10);
title('Figure 1'); xlabel('Temps [s]'); ylabel('Amplitude [A]');
wr.setstyle('Normal');
wr.addfigure();
%---
wr.addpagenumbers('wdAlignPageNumberRight');
wr.updatetoc();
%---
wr.close();
%---
open(reportFilename);
Do not hesitate to ask for more help and more advanced examples, especially when dealing with screenshots of Simulink models and Stateflow charts. I'll be happy to be of any assistance !
引用格式
Laurent Vaylet (2024). wordreport (https://www.mathworks.com/matlabcentral/fileexchange/17953-wordreport), MATLAB Central File Exchange. 检索时间: .
MATLAB 版本兼容性
平台兼容性
Windows macOS Linux类别
- Reporting and Database Access > Simulink Report Generator >
- Reporting and Database Access > MATLAB Report Generator >
- MATLAB > External Language Interfaces > COM with MATLAB > Use COM Objects in MATLAB > ActiveX >
标签
致谢
参考作品: WriteToWordFromMatlab
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!