You're absolutely right. Currently, MATLAB Report Generator's DOM API doesn't let you directly insert the full content of a Word document (like paragraphs, tables, etc.) into another Word report.
Since MATLAB doesn’t support this directly, there’s a workaround you can use by processing the Word file outside MATLAB and then recreating its content inside your report. Here's how you can do it:
Step 1: Extract the Word Content
Use an external tool to extract the content of the Word file using
python-docx, pandoc, Word automation via COM, etc.
This will give you the content in a readable format like plain text, HTML, or structured data.
Step 2: Parse the Content
- If it’s plain text, you can split it into paragraphs or lines.
- If its HTML, you can use an HTML parser (in MATLAB or Python) to identify headings, tables, etc.
Step 3: Rebuild the Content in MATLAB
Now, use MATLAB’s DOM API to recreate the content in your report like
- Use mlreportgen.dom.Paragraph to add paragraphs,
- Use mlreportgen.dom.Table to recreate tables,
- Use mlreportgen.dom.Text for formatting like bold or italic, etc.
PFA the links to the MathWorks documentation that explain how to use these DOM elements:
Hope this helps!