mlreportgen add content of word file

11 visualizaciones (últimos 30 días)
vivek patel
vivek patel el 15 de Oct. de 2022
Respondida: Akanksha el 17 de Jun. de 2025
In the mlreportgen, how can i add the content of the word file ?
I have tried mlreportgen.dom.DOCXSubDoc, but it would be still a link and need to manually remove the link, or through the matlab command. But i don't want to create many temporary files.
The same problem comes with mlreportgen.dom.EmbeddedObject.
Is there any way to add a full word document or a range of document, as an Paragraph to the mlreportgen ?

Respuestas (1)

Akanksha
Akanksha el 17 de Jun. de 2025
Hey vivek patel,
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!

Categorías

Más información sobre MATLAB Report Generator en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by