Can we use DocumentPart in Report Generation?

2 views (last 30 days)
I want to generate a Report with template. Can I use DocumentPart in report generation? Does DocumentPart support to report? if not please suggest some alternative solution. Thank you.
Here I am attaching small example
import mlreportgen.report.*
import mlreprtgen.dom.*
R = Report('Report', 'docx', 'Template');
append(R, DocumentPart(R, 'Content'))
close(R)
rptview(R)

Accepted Answer

SRUSHTI KHATAU
SRUSHTI KHATAU on 11 Nov 2021
This code works
import mlreportgen.report.*
import mlreportgen.dom.*
D = Template('NewTemplateName','docx','TemplateFromWhichWeAreAddingPart')
open(D)
dp = DocumentPart(D,'DocumenPartName');
append(D,dp)
close(D)
R = Report('Report','docx','NewTemplateName')
open(R)
append(R, TableOfContents)
close(R)
rptview(R)

More Answers (1)

Kevin Holly
Kevin Holly on 9 Nov 2021
It looks like it can from the example from the documentation.
  4 Comments
SRUSHTI KHATAU
SRUSHTI KHATAU on 11 Nov 2021
Thank you for replying. The above code was helpful.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!