主要内容

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

mlreportgen.report.ReportLayout 类

命名空间: mlreportgen.report

报告页面布局

描述

使用 mlreportgen.report.ReportLayout 类的对象指定报告页面布局选项,例如水印、首页编号、页码格式、页面大小和方向以及边距。

注意

报告创建此类的一个实例并将其分配给 mlreportgen.report.Report Layout 属性。您无需自己创建该对象。

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

类属性

HandleCompatible
true

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

属性

全部展开

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

有效的图像类型为:

  • .emf

  • .gif

  • .jpg

  • .pdf

  • .png

  • .svg

  • .tiff

注意

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

属性:

GetAccess
public
SetAccess
public

数据类型: char | string

报告中每个部分第一页使用的数字,指定为 [] 或正整数。例如,如果您将报告的第一页码设置为 4,则每个报告章节的第一页码都是 4。要对单个部分使用不同的首页码,请设置该部分的报告器使用的 mlreportgen.report.ReporterLayout 对象的 FirstPageNumber 属性。报告的默认编号是 [],表示第 1 章的第一页是第 1 页。报告中的所有后续页面均按顺序编号。

属性:

GetAccess
public
SetAccess
public

数据类型: int32

报告使用的页码类型,指定为字符向量或字符串标量。指定的页码格式将显示在报告的所有页面上。要对单个部分(例如章节)使用不同的页码格式,请设置该部分的报告器使用的 mlreportgen.report.ReporterLayout 对象的 PageNumberFormat 属性。请参阅 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。

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

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

toc = TableOfContents();
toc.Layout.PageNumberFormat = 'i';
append(rpt,toc);

ch = Chapter();
ch.Title = 'Introduction';
sec = Section('First Section of Chapter 1');
txt = ['This is the first section of chapter 1. ',...
      'The page number format is Arabic numbers, ',...
      'which is the default for the report.'];
append(sec,txt);
append(ch,sec);
append(rpt,ch); 

ch = Chapter(); 
ch.Title = '2nd chapter';
sec = Section('First Section of Chapter 2'); 
txt = ['This is the first section of chapter 2. ',...
      'The page number format is Arabic numbers, ',...
      'which is the format defined for the report.'];
append(sec,txt);
append(ch,sec);
append(rpt,ch);

close(rpt);
rptview(rpt);

版本历史记录

在 R2017b 中推出

全部展开