wordreport

版本 1.2.0.0 (34.2 KB) 作者: Laurent Vaylet
A Word report generator (ActiveX-based) in an object-oriented way
5.5K 次下载
更新时间 2009/7/6

查看许可证

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 版本兼容性
创建方式 R14SP3
兼容任何版本
平台兼容性
Windows macOS Linux
致谢

参考作品: WriteToWordFromMatlab

Community Treasure Hunt

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

Start Hunting!
版本 已发布 发行说明
1.2.0.0

Updated BSD Organization to The MathWorks, Inc

1.1.0.0

Updated license.txt to BSD

1.0.0.0

Now including a demo for a report generation including Simulink and Stateflow screenshots