Main Content Class


Report container


An object of the class is a container for a report based on reporters and MATLAB® and DOM objects. Use an object to generate an HTML, PDF, or Word report based on templates in a template library.

The class is a handle class.

Class Attributes


For information on class attributes, see Class Attributes.



report = returns a report container object with default property values.

report = sets the OutputPath property to path.


report =,type) also sets the Type property to type.

report =,type,template) also sets the TemplatePath property to template.

report = sets properties using name-value pairs. You can specify multiple name-value pair arguments in any order.


expand all

Path of generated report file, specified as a character vector or string scalar. The path is the location in the file system where the report output document is stored. The path can be a full path, for example, 'C:/myreports/reportA.docx'. The path can also be relative to the current MATLAB folder, for example, 'reportA'. If the file name does not have a file extension that corresponds to the Type property, the appropriate file extension is added.


Generating a PDF report on a cloud drive, such as MATLAB Drive™, can result in an error that is caused by file contention between the report generation software and the cloud drive synchronization software. To avoid this error, generate reports on a local drive that does not synchronize with the cloud. Consider writing a script that generates a report on a local drive and then copies the report to the cloud drive.

Packaging used for the generated files, specified as one of the values in the table.

ValueSupported Report TypesDescription


"docx", "html-multipage", or "html"

Generates the report as a zip file at the location specified by the OutputPath property. The zip file has an extension that matches the document type (docx for Word output or htmtx for HTML output.) For example, if the document type is docx and OutputPath is s:\docs\MyDoc, the output is packaged in a zip file named s:\docs\MyDoc.docx.


"docx", "html-multipage", or "html"

Generates the report as separate files in a folder that has the file name of the OutputPath property. For example, if the OutputPath is s:\docs\MyDoc, the output folder is s:\docs\MyDoc.


"docx", "html-multipage", or "html"

Generates zipped and unzipped outputs.


"pdf" or "html-file"

Generates the report as a single file.


When the Type property is "html" or "html-multipage", to generate an HTML report that you can open without unzipping, set PackageType to "unzipped" or "both". In the folder that contains the generated files, open the root.html file.



Data Types: char | string

Output type, specified as one of these values:

  • 'pdf' – PDF file.

  • 'html' – HTML report, packaged as a zipped file that contains the HTML file, images, style sheet, and JavaScript® files of the report. To generate an HTML report as a folder that contains unzipped files, set the PackageType property to 'unzipped' or 'both'.

  • 'html-file' – HTML report, consisting of a single HTML file that contains the text, style sheets, JavaScript, and base64-encoded images of the report.

  • 'docx'Microsoft® Word document.

If you specify a template using the TemplatePath property, the value for Type must match the template type.

Page layout options for this report, specified as an object. The initial value of the Layout property is an object with default values. Customize the page layout by modifying the property values. For an example, see Create a Landscape Report.

The layout options specified by the Layout property of objects of the,, and classes can override the page layout properties specified by the Layout property of an object.


The Layout property applies only to PDF and Word reports.

Locale or language, specified as a character vector or string scalar that consists of the ISO_639-1 two-letter language code of the locale for which this report is to be generated. The default value, [], specifies the language of the system locale, for example, English on an English system. The Report API uses the language code to translate chapter title prefixes to the language of the specified locale. Translations are provided for the following locales: 'af', 'ca', 'cs', 'da', 'de', 'el', 'en', 'es', 'et', 'eu', 'fi', 'fr', 'hu', 'id', 'it', 'ja', 'ko', 'nl', 'nn', 'no', 'pl', 'pt', 'ro', 'ru', 'sk', 'sl', 'sr', 'sv', 'tr', 'uk', 'xh', and 'zh'. If you specify an unsupported locale, the English version is used. See

For an example, see Translate Chapter Title Prefixes.

Location of the template used to format this report, specified as a character vector or string scalar. You can use this property to specify a custom template for the report.

Underlying DOM document object used to generate the content of the report, specified as an mlreportgen.dom.Document object. This property is read-only.

Report context, specified as a containers.Map object that contains information to generate the report, such as the hierarchical level of the current report section. This property is read-only.

Debug mode, specified as a numeric or logical 1 (true) or 0 (false). If you set Debug to true or 1, the temporary files for the report are stored in a subfolder of the report folder and are not deleted when the report is closed.


expand all


collapse all

Create a report using the Report API.

Import the DOM and Report API namespaces so that you do not have to use fully qualified class names.

import mlreportgen.dom.*

Create the report container.

rpt = Report('My Report','pdf');

Add a title page, table of contents, and chapter to the report. The chapter contains two sections, each of which contains an image.

append(rpt,TitlePage(Title='My Report'));
ch = Chapter('Images');
append(ch,Section(Title='Boeing 747',...

Create a report that has landscape orientation by using the Report API.

Import the Report API namespaces so that you do not have to use long, fully qualified class names.


Create a report container. In the object that is assigned to the Layout property, set the Landscape property to true.

rpt = Report('myreport','pdf');
rpt.Layout.Landscape = true;

Add content to the report. Generate and view the report.

append(rpt,TitlePage(Title='My Landscape Report'));
append(rpt,Chapter(Title='Unit Tests'));

Translate chapter title prefixes to Japanese on an English system by setting the Locale property.

rpt = Report('Japanese Report');
rpt.Locale = 'ja';
house = char(23478); % Kanji character for house
append(rpt, Chapter(house));

Version History

Introduced in R2017b

expand all