Create Report Programs
The MATLAB® Report Generator™ includes classes that allow you to create report generator programs. These programs can generate Word, HTML, and PDF reports. The programs must include certain items and can include some optional items, both of which are listed here and described at each associated link. For information on Report API and how it compares to the Document Object Model (DOM), see What Are Reporters?.
Required Report Program Tasks and Elements
All report generator programs must:
Create a report container. See Create Report Containers.
Report API Reporters
DOM API objects
MATLAB objects (doubles, cell arrays, MATLAB tables, strings, and so on)
Close the report container. See Close Reports.
Optional Report Program Tasks and Elements
Optionally, in report generator programs, you:
Import Report API classes, which enables using non-fully qualified Report API class names, for example,
TitlePage, instead of
mlreportgen.report.TitlePage. See Import API Packages.
Import DOM API classes, if the program adds DOM objects to the report, which enables using non-fully qualified DOM API class names.
Configure reporters by setting their property values. See Content Generation.
Add content to reporters by using the
The only reporters you can both configure and add content to are the
Chapterreporter is a subclass of the
Display the report to see the generated report output. See Display Reports.
Display report progress messages to monitor report progress. See Display Progress and Debugger Messages.
Report Generator Program Example
For example, this MATLAB code generates and displays a PDF report. It includes both required and optional items:
Run the following command to access the supporting files used in this example.
% Import report API classes (optional) import mlreportgen.report.* % Add report container (required) rpt = Report('output','pdf'); % Add content to container (required) % Types of content added here: title % page and table of contents reporters titlepg = TitlePage; titlepg.Title = 'My Airplane'; titlepg.Author = 'Pilot A'; add(rpt,titlepg); add(rpt,TableOfContents); % Add content to report sections (optional) % Text and formal image added to chapter chap = Chapter('Plane Image'); add(chap,'Here is the plane:'); add(chap,FormalImage('Image',... which('b747.jpg'),'Height','5in',... 'Width','5in','Caption','Boeing 747')); add(rpt,chap); % Close the report (required) close(rpt); % Display the report (optional) rptview(rpt);