Main Content

mlreportgen.dom.TemplateTableStyle Class

Namespace: mlreportgen.dom

Style table content within template

Since R2024a

Description

Use this class to create a Document Object Model (DOM) representation of a table style.

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

Class Attributes

HandleCompatible
true

For information on class attributes, see Class Attributes.

Creation

Description

styleObj = TemplateTableStyle creates a table style with an empty name. You must set the Name property to use the style.

example

styleObj = TemplateTableStyle(name) creates a table style and initializes the Name property to name. Add an instance of this object to the style sheet of the template specified by its Stylesheet property, to use this style to format tables based on the template. Set the StyleName property of the table to the name of this style to format the table as defined by the style.

Properties

expand all

Name of the style, specified as a string scalar or character vector.

Note

The name must include only letters, numbers, hyphens (-), and underscores (_).

Attributes:

NonCopyable
true

Data Types: char | string

Style sheet formats, specified as an array of DOM formatting objects. These formats define how this style affects report content.

Attributes:

NonCopyable
true

Table entry formats, specified as an array of DOM formatting objects. These formats apply to every table entry in tables that use this style.

Attributes:

NonCopyable
true

Table header formats, specified as an array of DOM formatting objects. These formats apply to every table header in tables that use this style.

Attributes:

NonCopyable
true

Table footer formats, specified as an array of DOM formatting objects. These formats apply to every table footer in tables that use this style.

Attributes:

NonCopyable
true

First column of a table formats, specified as an array of DOM formatting objects. These formats apply to the first column of tables that use this style.

Note

The PDF template output ignores this property.

Attributes:

NonCopyable
true

Last column of a table formats, specified as an array of DOM formatting objects. These formats apply to the first column of tables that use this style.

Note

The PDF template output ignores this property.

Odd columns of a table formats, specified as an array of DOM formatting objects. These formats apply to the first column of tables that use this style.

Note

The PDF template output ignores this property.

Attributes:

NonCopyable
true

Even columns of a table formats, specified as an array of DOM formatting objects. These formats apply to the first column of tables that use this style.

Note

The PDF template output ignores this property.

Attributes:

NonCopyable
true

Odd rows of a table formats, specified as an array of DOM formatting objects. These formats apply to the first column of tables that use this style.

Note

The PDF template output ignores this property.

Attributes:

NonCopyable
true

Even rows of a table formats, specified as an array of DOM formatting objects. These formats apply to the first column of tables that use this style.

Note

The PDF template output ignores this property.

Attributes:

NonCopyable
true

Top left entry of a table formats, specified as an array of DOM formatting objects. These formats apply to the first column of tables that use this style.

Note

The PDF template output ignores this property.

Attributes:

NonCopyable
true

Top right entry of a table formats, specified as an array of DOM formatting objects. These formats apply to the first column of tables that use this style.

Note

The PDF template output ignores this property.

Attributes:

NonCopyable
true

Bottom left entry of a table formats, specified as an array of DOM formatting objects. These formats apply to the first column of tables that use this style.

Note

The PDF template output ignores this property.

Attributes:

NonCopyable
true

Bottom right entry of a table formats, specified as an array of DOM formatting objects. These formats apply to the first column of tables that use this style.

Note

The PDF template output ignores this property.

Attributes:

NonCopyable
true

Tag for mlreportgen.dom.TemplateTableStyle 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

Object identifier for mlreportgen.dom.TemplateTableStyle 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

Examples

collapse all

Create a table style in a template and then apply that style in your document.

Create the style

Import the DOM API namespace so that you do not have to use fully qualified names.

import mlreportgen.dom.*;
t = Template("myTemplate","html");
open(t);

Create a table style.

tableStyle = TemplateTableStyle("myTableStyle");

Define formats for the table style.

tableStyle.Formats = [Border("solid"), ColSep("solid"), RowSep("solid")];
tableStyle.OddRowFormats = [BackgroundColor("lightblue")];

Add the style to the style sheet.

addStyle(t.Stylesheet,tableStyle);

Close the template.

close(t);

Use the style from the template in a document

Create a document using the generated template.

d = Document("myDoc","html","myTemplate");
open(d);

Create a table object.

tbl = Table(randi(10,[4 4]));

Set the style name.

tbl.StyleName = "myTableStyle";

Add the table to the document.

append(d,tbl);

Close and view the document.

close(d);
rptview(d);

Version History

Introduced in R2024a