TheMATLAB®Report Generator™包括g类允许您创建报告enerator 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), seeWhat Is a Reporter?.
All report generator programs must:
创建一个代表ort container. SeeCreate Report Container.
Create and add content to the container. SeeAdd Content to a ReportandContent Generation. The content can be
Report API Reporters
DOM API objects
MATLAB objects (doubles, cell arrays, MATLAB tables, strings, and so on)
Close the report container. SeeClose a Report.
Optionally, in report generator programs, you:
Import Report API classes, which enables using non-fully qualified Report API class names, for example,TitlePage
, instead ofmlreportgen.report.TitlePage
. SeeImport the 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. SeeContent Generation.
Add content to reporters by using theadd
method.
Note
The only reporters you can both configure and add content to are theSection
andChapter
reporters. TheChapter
reporter is a subclass of theSection
reporter.
Display the report to see the generated report output. SeeDisplay Report.
Display report progress messages to monitor report progress. SeeDisplay Progress and Debugger Messages.
For example, this MATLAB code generates and displays a PDF report. It includes both required and optional items:
% Import report API classes (optional)importmlreportgen.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 reporterstitlepg = 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 chapterchap = 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);