The extent of the use of the content with a Word template file is a common misconception when working with Simulink Report Generator. The only parts of a Word template which are used during the report generation process is the definition of the styles for the various sections. Any content of formatting on the page will have no effect on the output of the report other than to act as a prefix for the generated report. While this is not possible to merge into a Word document using a direct workflow in Simulink Report Generator, there are two possible approaches which can generate comparable results:
1) It is possible to import data into an existing Word document using MATLAB Report Generator. In order to utilize this approach to report on a Simulink model, you will need to place the relevant information into the MATLAB Workspace. This can be done by a combination of outputs from the Simulink model and MATLAB scripts to query the model. For more information on how to write to an existing Word document using MATLAB Report Generator, please see the documentation link below.
2) A secondary approach to the one described above allows the combination of various word documents into a single output file. This approach will require separation of the existing formatted report into a number of separate files but will also permit entire formatted sections generated from Simulink Report Generator to be used directly. This is useful if you are only interested in adding for example a title page or handwritten report section.
The example script below assumes two existing word files for the Simulink report and custom prefix respectively. It will combine them into a single report and open it as a single document.
import mlreportgen.dom.*;
report = DOCXSubDoc(reportFile);
prefix = DOCXSubDoc(prefixFile);
doc = Document('outputFile','docx');
append(doc,prefix);
append(doc,report);
close(doc);
docview(doc.OutputPath, 'unlinkdocxsubdoc', 'savedoc', 'closeapp');
winopen(doc.OutputPath);
Note: This workflow relies on the R2016b option ‘unlinkdocxsubdoc’ in order to work. Without this option, the Word file will be made up of subdocuments which can be unlinked manually via the outline view in Word.
Best Answer