主要内容

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

mlreportgen.report.ReporterLayout 类

命名空间: mlreportgen.report

报告器版面

描述

使用 mlreportgen.report.ReporterLayout 类的对象指定报告部分的页面布局选项,例如标题页、目录、图窗列表、表列表、题注列表或章节。页面布局选项包括水印、首页编号、页码格式、页面大小和方向以及边距。

注意

当您为报告部分创建报告器时,将创建此类的一个实例并将其分配给报告器 Layout 属性。您无需自行创建该对象。

mlreportgen.report.ReporterLayout 类是一个 handle 类。

类属性

HandleCompatible
true

有关类属性的信息,请参阅类属性

属性

全部展开

水印图像,指定为 [] 或者包含图像路径名的字符向量或字符串标量。在打开报告之前,必须设置此属性。水印出现在报告部分的所有页面上。如果 Watermark 属性为 [],则该部分的水印与报告的水印相同。如果报告部分和报告的布局对象的 Watermark 属性为 [],则不会出现水印。

有效的图像类型为:

  • .emf

  • .gif

  • .jpg

  • .pdf

  • .png

  • .svg

  • .tiff

注意

只有 PDF 报告才能添加水印。其他报告类型会忽略此属性的内容。

属性:

GetAccess
public
SetAccess
public

数据类型: char | string

报告部分第一页上使用的数字,指定为整数或 []。如果该属性的值为 -1[],则从上一部分继续编号。要指定第一页的页码,请输入一个正整数。

注意

默认第一章第一页的页码为 1。

属性:

GetAccess
public
SetAccess
public

数据类型: int32

Word 或 PDF 报告中报告部分使用的页码类型,指定为字符向量或字符串标量。请参阅 mlreportgen.dom.PageNumber 中的 Format 属性,了解有效页码格式的列表。

属性:

GetAccess
public
SetAccess
public

数据类型: char | string

报告部分的页面方向,指定为 truefalse。将此属性设置为 true 可将纵向方向更改为横向方向,设置为 false 可将横向方向更改为纵向方向。如果值为 [],则方向由报告部分布局指定的页面大小决定。

属性:

GetAccess
public
SetAccess
public

数据类型: logical

布局中页面的大小,指定为 mlreportgen.dom.PageSize 对象。

属性:

GetAccess
public
SetAccess
public
NonCopyable
true

此布局的页边距、页眉、页脚和装订边距的大小,指定为 mlreportgen.dom.PageMargins 对象。

属性:

GetAccess
public
SetAccess
public

布局的页面边框,指定为 mlreportgen.dom.PageBorder 对象。

属性:

GetAccess
public
SetAccess
public
NonCopyable
true

示例

全部折叠

在报告中添加三个章节。第一章使用默认的页码值,即 1,以及默认的页面方向,即纵向。第二章将首页页码重置为 1,并使用横向页面方向。第三章未设置页码和方向,因此它使用默认的第一页码(延续上一章)和默认页面方向(纵向)。

import mlreportgen.report.*
rpt = Report('newreport'); 

添加标题页。

tp = TitlePage();
tp.Title = 'New Report'; 
tp.Author = 'MathWorks'; 
add(rpt,tp)

添加第一章,默认编号从 1 开始,默认页面方向设置为纵向。

ch1 = Chapter();
ch1.Title = 'First Chapter';
sec = Section('First Section of Chapter 1');
txt = ['This is the first section of chapter 1. ',...
      'The first page number for this ',...
      'chapter is 1, which is the default. ',...
      'The page orientation is also the default.']; 
append(sec,txt);
append(ch1,sec);
append(rpt,ch1); 

添加第二章,将编号重置为 1,并将页面方向设置为横向。

ch2 = Chapter(); 
ch2.Title = '2nd chapter';
ch2.Layout.FirstPageNumber = 1;
ch2.Layout.Landscape = true;
sec = Section('First Section of Chapter 2'); 
txt = ['This is the first section of chapter 2. ',...
      'The first page number is set to 1 and the ',...
      'page orientation is set to landscape.'];
append(sec,txt);
append(ch2,sec);
append(rpt,ch2);

添加第三章,不设置起始页码或页面方向。这将导致章节恢复为默认设置,即从上一页继续进行页码编排和纵向页面方向。

ch3 = Chapter(); 
ch3.Title = '3rd chapter';
sec = Section('First Section of Chapter 3'); 
txt = ['This is the first section of chapter 3. ',...
      'Neither first page number nor page ',...
      'orientation is set for this chapter. ',...
      'The first page number uses the default, ',...
      'which continues from the previous page. ',...
      'The page orientation also uses the default, ',...
      'which is portrait.'];
append(sec,txt);
append(ch3,sec);
append(rpt,ch3);

关闭并查看报告。

close(rpt);
rptview(rpt)

版本历史记录

在 R2017b 中推出

全部展开