Main Content

mlreportgen.dom.RepeatAsHeaderRow class

Package: mlreportgen.dom
Superclasses:

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.

Construction

repeatAsHeaderRowObj = RepeatAsHeaderRow() repeats the table row on each page when the table flows across multiple pages.

repeatAsHeaderRowObj = RepeatAsHeaderRow(onOff) repeats the table row on each page when onOff is true.

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.

Input Arguments

expand all

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 page when the table flows across multiple pages.

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

Data Types: logical

Properties

expand all

ID for this document element, specified as a character vector or string scalar. The DOM generates a session-unique ID when it creates the document element. You can specify your own ID.

Tag for this document element, specified as a character vector or string scalar.

The DOM 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. Specifying your own tag value can help you to identify where an issue occurred during document generation.

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);