Main Content

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

mlreportgen.dom.CounterInc 类

命名空间: mlreportgen.dom

数字流计数器增量器

描述

创建编号流计数器增量器。

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

创建对象

描述

counterIncObj = CounterInc 创建一个空的计数器增量器。

示例

counterIncObj = CounterInc(streamNames) 为每个指定的编号流创建一个计数器增量器。将此格式分配给 DOM 对象的样式会导致在将对象追加到文档时关联的流计数器递增。

输入参量

全部展开

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

属性

全部展开

mlreportgen.dom.CounterInc 对象的对象标识符,指定为字符向量或字符串标量。DOM API 在创建文档元素对象时会生成一个会话唯一标识符。您可以为 Id 指定自己的值。

属性:

NonCopyable
true

数据类型: char | string

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

mlreportgen.dom.CounterInc 对象的标签,指定为字符向量或字符串标量。DOM API 在创建此对象的过程中生成一个会话唯一标签。生成的标签形式为 CLASS:ID,其中 CLASS 是对象类,ID 是对象的 Id 属性的值。指定您自己的标签值,以帮助您确定在文档生成过程中出现问题时要查找的位置。

属性:

NonCopyable
true

数据类型: char | string

示例

全部折叠

import mlreportgen.dom.*;
doctype = 'html';
d = Document('test',doctype);
     
p = Paragraph('Chapter ');
p.Style = {CounterInc('chapter'),WhiteSpace('preserve')};
append(p,AutoNumber('chapter'));
append(d,p);
     
p = Paragraph('Chapter ');
p.Style = {CounterInc('chapter'), WhiteSpace('preserve')};
append(p,AutoNumber('chapter'));
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 中推出