Main Content

Construct Report API or DOM API Objects

The Report API and DOM API include a set of MATLAB® functions, called constructors, for creating objects of various types, or classes.

The name of an object constructor is the name of the MATLAB class from which the API creates an object.

Construct Report API Objects

The qualifier for Report API constructor names is mlreportgen.report. For example, the name of the constructor for a Report API chapter object is mlreportgen.report.Chapter. Some constructors do not require any arguments. Other constructors can take one or more arguments that typically specify its content and properties. For example, this code creates a chapter whose title is My Chapter.

chap = mlreportgen.report.Chapter('My Chapter');

A constructor returns a handle to the object it creates. Assigning the handle to a variable allows you to add content to the object or set its properties. For example, this code adds a section with a title to the chapter object chap.

append(chap,Section('Detailed Description'));

Construct DOM API Objects

The qualifier for DOM API constructor names is mlreportgen.dom. For example, the name of the constructor for a DOM paragraph object is mlreportgen.dom.Paragraph. Some constructors do not require any arguments. Other constructors can take one or more arguments that typically specify its initial content and properties. For example, this code creates a paragraph whose initial content is Chapter 1.

para = mlreportgen.dom.Paragraph('Chapter 1.');

A constructor returns a handle to the object it creates. Assigning the handle to a variable allows you to append content to the object or set its properties. For example, this code appends content to the paragraph object para.

append(para,'In the Beginning');

Related Topics