Main Content

mlreportgen.dom.RepeatAsHeaderRow Class

Namespace: mlreportgen.dom

Repeat table row

Description

Use objects of the mlreportgen.dom.RepeatAsHeaderRow class to specify whether the table row repeats on each page when the table flows across multiple pages. You can use this object only with Microsoft® Word documents.

Note

You can use this object for the first row of the table and any immediately consecutive rows. If a row is not set to repeat over pages, then successive rows cannot be set to repeat over pages. If you apply this object to rows that follow non-repeating rows, this object is ignored.

The mlreportgen.dom.RepeatAsHeaderRow class is a handle class.

Creation

Description

repeatAsHeaderRowObj = RepeatAsHeaderRow creates an mlreportgen.dom.RepeatAsHeaderRow object and sets the Value property to true.

example

repeatAsHeaderRowObj = RepeatAsHeaderRow(value) creates an mlreportgen.dom.RepeatAsHeaderRow object and sets the Value property to value.

Properties

expand all

Object identifier for mlreportgen.dom.RepeatAsHeaderRow object, specified as a character vector or string scalar. The DOM API generates a session-unique identifier when it creates the document element object. You can specify your own value for Id.

Attributes:

NonCopyable
true

Data Types: char | string

Tag for mlreportgen.dom.RepeatAsHeaderRow object, specified as a character vector or string scalar. The DOM API generates a session-unique tag as part of the creation of this object. The generated tag has the form CLASS:ID, where CLASS is the object class and ID is the value of the Id property of the object. Specify your own tag value to help you identify where to look when an issue occurs during document generation.

Attributes:

NonCopyable
true

Data Types: char | string

Whether the table row repeats on each page, specified as a numeric or logical 1 (true) or 0 (false), where:

  • true or 1 — The table row repeats on each new page when a table flows across multiple pages.

  • false or 0 — The table row does not repeat.

Data Types: logical

Examples

collapse all

Create an mlreportgen.dom.Document of type docx.

import mlreportgen.dom.*;
document = Document("Repeat_Rows_Doc","docx");

Create an mlreportgen.dom.Table with one column and 30 rows of mlreportgen.dom.Text objects, then set the text of the table rows.

append(document,"Table 1:");
table1 = Table(arrayfun(@(x) Text(),ones(30,1)));
table1.entry(1,1).Children(1).Content = "Header 1, does not repeat across pages";
table1.entry(2,1).Children(1).Content = "Header 2, does not repeat across pages";
for rowInd = 3:30
  table1.entry(rowInd,1).Children(1).Content = sprintf("Row %i of Table 1",rowInd);
end

Set the style for the table borders and separators, then append the table to the document.

table1.Style = [table1.Style,{Border("solid"),RowSep("solid")}];
append(document,table1);

Create a second table with one column and 30 rows of Text objects, then set the text of the table rows.

append(document,LineBreak());
append(document,LineBreak());
append(document,"Table 2:");
table2 = Table(arrayfun(@(x) Text(),ones(30,1)));
table2.entry(1,1).Children(1).Content = "Header 1, repeats across pages";
table2.entry(2,1).Children(1).Content = "Header 2, repeats across pages";
for rowInd = 3:30
  table2.entry(rowInd,1).Children(1).Content = sprintf("Row %i of Table 2",rowInd);
end

Set the first two rows of the table to repeat across pages. Then set the style for the table borders and separators, and append the table to the document.

table2.row(1).Style = [table2.row(1).Style,{RepeatAsHeaderRow(true)}];
table2.row(2).Style = [table2.row(2).Style,{RepeatAsHeaderRow(true)}];
table2.Style = [table2.Style,{Border("solid"),RowSep("solid")}];
append(document,table2);

Close the document to generate the report, then open the report.

close(document);
rptview(document);

Version History

Introduced in R2014b