Main Content

本页采用了机器翻译。点击此处可查看最新英文版本。

创建章节

您可以使用 mlreportgen.report.Chapter 类将章节添加到报告中。使用此类创建章节比使用 DOM 对象要容易得多,而且效率更高。Chapter 类继承自 mlreportgen.report.SectionChapter 类会自动将格式化的章节添加到您的报告中。默认格式是纵向,带有页眉和页脚。页脚包含页码。您可以覆盖章节的布局。

有关信息和示例,请参阅 mlreportgen.report.Chapter

此示例显示创建标题页并将其页面方向设置为横向的代码。

运行以下命令来访问本示例中使用的支持文件。

openExample('rptgen/MatlabReportGeneratorSupportFilesExample');
import mlreportgen.report.*
import mlreportgen.dom.*

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

add(rpt,TitlePage('Title','My Report'));

chapter = Chapter('Images');
chapter.Layout.Landscape = true;
add(chapter,Section('Title','Boeing 747', ...
     'Content',Image(which('b747.jpg'))));

add(rpt,chapter);
close(rpt);
rptview(rpt);

Chapter one with a picture of a Boeing 747