主要内容

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

mlreportgen.dom.CounterReset 类

命名空间: mlreportgen.dom

重置编号流计数器

描述

重置编号流计数器。

mlreportgen.dom.CounterReset 类是一个 handle 类。

创建对象

描述

counterResetObj = CounterReset 创建一个空的计数器重置对象。

counterResetObj = CounterReset(streamNames) 为每个指定的编号流创建一个计数器重置器。将此格式分配给 DOM 对象的样式会导致在将对象追加到文档时将相关的流计数器重置为其初始值。

示例

输入参量

全部展开

编号流名称,指定为字符向量或字符串标量。要指定多个流名称,请在流名称之间添加空格。

属性

全部展开

目标标识符,指定为字符向量或字符串标量。DOM API 在创建文档元素对象时会生成一个会话唯一标识符。

属性:

GetAccess
public
SetAccess
public
NonCopyable
true

数据类型: char | string

编号流名称,指定为字符向量或字符串标量。要指定多个流名称,请在流名称之间添加空格。

标记,指定为字符向量或字符串标量。DOM API 在创建此对象的过程中生成一个会话唯一标记。生成的标记形式为 CLASS:ID,其中 CLASS 是对象类,ID 是对象的 Id 属性的值。使用此值来帮助确定在文档生成过程中出现的问题的位置。

属性:

GetAccess
public
SetAccess
public
NonCopyable
true

数据类型: char | string

示例

全部折叠

import mlreportgen.dom.*;
doctype = 'html';
d = Document('test',doctype);
     
p = Paragraph('Chapter ');
p.Style = {CounterInc('chapter'),CounterReset('table'),...
   WhiteSpace('preserve') };
append(p,AutoNumber('chapter'));
append(d,p);
     
p = Paragraph('Table ');
append(p,AutoNumber('chapter'));
append(p,'.');
append(p,AutoNumber('table'));
p.Style = {CounterInc('table'),WhiteSpace('preserve') };
append(d,p);
     
p = Paragraph('Chapter ');
p.Style = {CounterInc('chapter'),CounterReset('table'),...
   WhiteSpace('preserve')};
append(p,AutoNumber('chapter'));
append(d,p);
     
p = Paragraph('Table ');
append(p,AutoNumber('chapter'));
append(p,'.');
append(p, AutoNumber('table'));
p.Style = {CounterInc('table'),WhiteSpace('preserve')};
append(d,p);
     
close(d);
rptview('test',doctype);

为章节以及章节内的图窗指定多个计数器流。

import mlreportgen.dom.*
rpt = Document('MyReport','pdf');

chapterStyle = {WhiteSpace('pre'), ...
    CounterReset('table figure'), ...
    CounterInc('chapter') ...
    };

topicChapterStyle = {WhiteSpace('pre'), ...
    CounterReset('table figure'), ...
    CounterInc('chapter topic') ...
    };

figureStyle = {WhiteSpace('pre'), ...
    CounterInc('figure'),Italic(true)};

chapter = Heading(1,'Chapter: ');
chapter.Style = chapterStyle;
append(chapter,AutoNumber('chapter'));
append(chapter,' Introduction to number streams.');
append(rpt, chapter);

image = append(rpt,Image(which('b747.jpg')));
image.Width = '2in';
image.Height = '2in';
para = append(rpt, Paragraph('Figure '));
para.Style = figureStyle;
append(para, AutoNumber('chapter'));
append(para, '.');
append(para, AutoNumber('figure'));

image = append(rpt,Image(which('ngc6543a.jpg')));
image.Width = '2in';
image.Height = '2in';
para = append(rpt,Paragraph('Figure '));
para.Style = figureStyle;
append(para, AutoNumber('chapter'));
append(para, '.');
append(para, AutoNumber('figure'));


chapter = Heading(1, 'Chapter: ');
chapter.Style = topicChapterStyle;
append(chapter, AutoNumber('chapter'));
append(chapter,' Topic: ');
append(chapter,AutoNumber('topic'));
append(chapter,' How to reset and increment streams.');
append(rpt,chapter);

image = append(rpt,Image(which('b747.jpg')));
image.Width = '2in';
image.Height = '2in';
para = append(rpt,Paragraph('Figure '));
para.Style = figureStyle;
append(para, AutoNumber('chapter'));
append(para, '.');
append(para, AutoNumber('figure'));


close(rpt);
rptview(rpt.OutputPath);

版本历史记录

在 R2014b 中推出