(Not recommended) Add content to report
You can add a reporter to a report multiple times, but you cannot add the reporter
to different reports. For example, if you add an
mlreportgen.report.TitlePage reporter to one report, you cannot
add it to another report.
report — Report
Report, specified as an
content — Content to add to report
Report API reporter | DOM object | MATLAB built-in object
Content to add to report, specified as a Report API reporter, DOM object, or built-in MATLAB® object. The content can be a Report API reporter or any object that you can append to a DOM document. Content that you can append to a DOM document includes DOM objects and many built-in MATLAB objects, such as strings, character arrays, and cell arrays.
Add Content to a Report
Add content to a paragraph and add the paragraph to a report.
To add the content to the paragraph, you must use
because a paragraph is a DOM API object. To add the paragraph to the report,
which is a Report API object, this example uses
in R2020b, you can use
append instead of
See Compatibility Considerations.
import mlreportgen.dom.* import mlreportgen.report.* rpt = Report("My Report"); p = Paragraph("My paragraph content "); append(p,"and some more content."); add(rpt,p); close(rpt); rptview(rpt);
Version HistoryIntroduced in R2017b
add method is not recommended
Not recommended starting in R2020b
Starting in R2020b, use the
append method instead of the
add method to add content to objects of these Report API classes:
To add content to a DOM API object, such as an
mlreportgen.dom.Paragraph object, continue to use the
append method of the DOM object. The advantage of using
append to add content to Report API objects is that you use
the same method name as you use to add content to DOM API objects.
There are no plans to remove the
add methods of the
classes. Report API programs that use the
add methods will continue
To update existing code, replace the method name
append as shown by the examples in the table.
import mlreportgen.report.* import mlreportgen.dom.* rpt = Report("My Report","pdf"); ch = Chapter("My Chapter"); sect = Section("My Section"); para = Paragraph("My Content "); append(para,"more Content"); add(sect,para); add(ch,sect); add(rpt,ch); close(rpt); rptview(rpt);
import mlreportgen.report.* import mlreportgen.dom.* rpt = Report("My Report","pdf"); ch = Chapter("My Chapter"); sect = Section("My Section"); para = Paragraph("My Content "); append(para,"more Content"); append(sect,para); append(ch,sect); append(rpt,ch); close(rpt); rptview(rpt);