add
Class: mlreportgen.report.Section
Namespace: mlreportgen.report
(Not recommended) Add content to section
Syntax
add(section,content)
Description
Note
add
is not recommended. Use append
instead. See Version History.
add(
adds the specified content to the specified section.section
,content
)
Input Arguments
section
— Section of the report
mlreportgen.report.Section
object
Section of the report, specified as an mlreportgen.report.Section
object.
content
— Content to add to section
Report API reporter | DOM object | MATLAB built-in object | cell array of objects
Content to add to the section, specified as one of these values:
Report API reporter
DOM object
Built-in MATLAB® object (most built-in MATLAB objects can be added to a
Section
reporter)Cell array of objects that can be added individually to a section
Examples
Add Content to Report Section
Add content to a paragraph and add the paragraph to a section
of a chapter. To add the content to the paragraph, you must use
append
because a paragraph is a DOM API object. To add the
paragraph to the section, the section to the chapter, and the chapter to the
report, this example uses add
. Starting in R2020b, you can use
append
instead of add
. See Version History.
import mlreportgen.dom.* import mlreportgen.report.* rpt = Report("My Report"); ch = Chapter("My Chapter"); s = Section("My Section"); p = Paragraph("My paragraph content "); append(p,"and some more content."); add(s,p); add(ch,s); add(rpt,ch); close(rpt); rptview(rpt);
Version History
Introduced in R2017bR2020b: add
method is not recommended
Starting in R2020b, use the append
method instead of the
add
method to add content to objects of these Report API classes:
mlreportgen.report.Report
mlreportgen.report.Chapter
mlreportgen.report.Section
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
Report
, Chapter
, or Section
classes. Report API programs that use the add
methods will continue
to run.
To update existing code, replace the method name add
with
append
as shown by the examples in the table.
Not Recommended | Recommended |
---|---|
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); |
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)