Main Content

mlreportgen.dom.Table class

Package: mlreportgen.dom

Informal table

Description

Use objects of the mlreportgen.dom.Table class to define an informal table, which is a table that has only a body. It does not have separate header or footer sections.

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

Class Attributes

HandleCompatible
true
ConstructOnLoad
true

Creation

Description

tableObj = mlreportgen.dom.Table(nCols) creates an empty table and sets the NCol property to nCols. Use this syntax as the starting point for creating a table.

example

tableObj = mlreportgen.dom.Table(array) creates a table whose content is specified by array. The constructor converts basic MATLAB® types to corresponding DOM types. For example, it changes character vectors to mlreportgen.dom.Text objects.

tableObj = mlreportgen.dom.Table(array,style) creates a table and sets the Style property to style. The style specified by style must be defined in the template used to create the document to which this table is appended.

Input Arguments

expand all

Table body content, specified as:

  • A two-dimensional numeric array

  • A two-dimensional categorical array

  • A two-dimensional string array

  • A two-dimensional cell array that contains arrays, data types, or objects of these type:

    • Character vector

    • String scalar

    • One-dimensional or two-dimensional cell array

    • Items of data type double

    • mlreportgen.dom.Text object

    • mlreportgen.dom.Paragraph object

    • mlreportgen.dom.Image object

    • mlreportgen.dom.Table object

    • mlreportgen.dom.FormalTable object

    • mlreportgen.dom.OrderedList object

    • mlreportgen.dom.UnorderedList object

    • mlreportgen.dom.ExternalLink object

    • mlreportgen.dom.InternalLink object

    • mlreportgen.dom.CharEntity object

    • mlreportgen.dom.LineBreak object

Properties

expand all

Table background color, specified as a character vector or string scalar that consists of a CSS color name or a hexadecimal RGB value.

Setting the BackgroundColor property adds a mlreportgen.dom.BackgroundColor format object to the Style property. Setting the BackgroundColor property to an empty value removes the object.

Example: "blue"

Example: "#0000ff"

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Type of border to draw, specified as one of the values in the table.

Border ValueDescriptionSupported Output Types

"dashed"

Dashed line

All output types

"dashdotstroked"

Line with alternating diagonal dashes and dot

Word

"dashsmallgap"

Dashed line with a small gap between dashes

Word

"dotted"

Dotted line

All output types

"dotdash"

Line with alternating dots and dashes

Word

"dotdotdash"

Line with alternating double dots and a dash

Word

"double"

Double line

All output types

"doublewave"

Double wavy line

Word

"groove"

3-D effect grooved line

HTML and PDF

"hidden"

No line

The "none" border type also produces no line. However, conflicting borders are handled differently for "hidden" types than for "none" types. The "hidden" border type takes precedence over a conflicting border type. A conflicting border type takes precedence over the "none" type.

HTML and PDF

"inset"

3-D effect line

All output types

"none"

No line

The "hidden" border type also produces no line. However, conflicting borders are handled differently for "hidden" types than for "none" types. The "hidden" border type takes precedence over a conflicting border type. A conflicting border type takes precedence over the "none" type.

All output types

"outset"

3-D effect line

All output types

"ridge"

3-D effect ridged line

HTML and PDF

"single"

Single line

Word

"solid"

Single line

HTML and PDF

"thick"

Thick line

Word

"thickthinlargegap"

Dashed line with alternating thick and thin dashes with a large gap

Word

"thickthinmediumgap"

Dashed line with alternating thick and thin dashes with a medium gap

Word

"thickthinsmallgap"

Dashed line with alternating thick and thin dashes with a small gap

Word

"thinthicklargegap"

Dashed line with alternating thin and thick dashes with a large gap

Word

"thinthickmediumgap"

Dashed line with alternating thin and thick dashes with a medium gap

Word

"thinthicksmallgap"

Dashed line with alternating thin and thick dashes with a small gap

Word

"thinthickthinlargegap"

Dashed line with alternating thin and thick dashes with a large gap

Word

"thinthickthinmediumgap"

Dashed line with alternating thin and thick dashes with a medium gap

Word

"thinthickthinsmallgap"

Dashed line with alternating thin and thick dashes with a small gap

Word

"threedemboss"

Embossed effect line

Word

"threedengrave"

Engraved effect line

Word

"triple"

Triple line

Word

"wave"

Wavy line

Word

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

A value of "on" collapses borders of adjacent cells into a single border. A value of "off" keeps borders of adjacent cells. This property applies only to HTML documents.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Table border color, specified as a character vector or string scalar that consists of a CSS color name or a hexadecimal RGB value.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Table border width, specified as a string scalar or character vector that consists of a number followed by an abbreviation of a unit of measurement. Valid abbreviations are:

  • px — pixels (default)

  • cm — centimeters

  • in — inches

  • mm — millimeters

  • pc — picas

  • pt — points

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Children of this DOM API object, specified as an array of DOM API objects.

Attributes:

GetAccess
public
SetAccess
private
NonCopyable
true

Style of the line that separates the columns of a table, specified as a character vector or string scalar.

See the description of the attribute Border for a description of the possible values.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Color of line separating columns, specified as a character vector or string scalar that consists of a CSS color name or a hexadecimal RGB value.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Width of the line separating table columns, specified as a string scalar or character vector that consists of a number followed by an abbreviation of a unit of measurement. Valid abbreviations are:

  • px — pixels (default)

  • cm — centimeters

  • in — inches

  • mm — millimeters

  • pc — picas

  • pt — points

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Width, alignment, and other properties of a group of columns, specified as an array of mlreportgen.dom.TableColSpecGroup objects. The first object applies to the first group of columns, the second object to the second group, and so on. Specify the number of columns belonging to each group by using the Span property of the TableColSpecGroup object. For example, if the first object has a span of 2, it applies to the first two columns. If the second group has a span of 3, it applies to the next three columns, and so on.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Custom attributes for the table, specified as an array of mlreportgen.dom.CustomAttribute objects. The custom attributes must be supported by the output type of the document to which this document element is appended.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Direction for text to flow, specified as one of these values:

  • "ltr" — Text flows from left to right

  • "rtl" — Text flows from right to left

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Horizontal alignment of this table, specified as one of these values:

  • "center"

  • "left"

  • "right"

Note

To prevent the overflow of large tables in PDF output, set the Width property.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

ID for this DOM API object, 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.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Whether the table contents stay on the same page, specified as a numeric or logical 1 (true) or 0 (false). The default value is empty and is equivalent to true.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Data Types: logical

Number of table columns, specified as an integer. To specify the number of columns, create a table by using the syntax mlreportgen.dom.Table(nCols). Otherwise, the Table constructor determines the number of columns from the table content. If you add rows to a table or entries to a row and the number of columns changes, the value of the NCols property updates. If the rows do not all have the same number of entries, the row with the largest number of table entries determines the number of columns in the table.

Attributes:

GetAccess
public
SetAccess
private
NonCopyable
true

Number of rows in this table, specified as an integer. The Table constructor determines the number of rows from the table content. If you add rows to the table, the value of the NRows property updates.

Attributes:

GetAccess
public
SetAccess
private
NonCopyable
true

Left margin of the table, specified as a string scalar or character vector that consists of a number followed by an abbreviation of a unit of measurement. Valid abbreviations are:

  • px — pixels (default)

  • cm — centimeters

  • in — inches

  • mm — millimeters

  • pc — picas

  • pt — points

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Parent of this DOM API object, specified as a DOM API object.

Attributes:

GetAccess
public
SetAccess
private
NonCopyable
true

Style of the lines that separate the rows of a table, specified as a character vector or string scalar.

See the description of the Border property for a description of the possible values.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Color of lines separating table rows, specified as a character vector or string scalar that consists of a CSS color name or a hexadecimal RGB value.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Width of the lines that separates the table rows, specified as a string scalar or character vector that consists of a number followed by an abbreviation of a unit of measurement. Valid abbreviations are:

  • px — pixels (default)

  • cm — centimeters

  • in — inches

  • mm — millimeters

  • pc — picas

  • pt — points

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Formats that define the style of this table, specified as a cell array of DOM format objects. The formats override the corresponding formats defined by the stylesheet style specified by the StyleName property.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Name of a style specified in the style sheet of the document or document part to which this table is appended, specified as a character vector or string scalar.

The style specified by the StyleName property must be defined in the stylesheet of the document or document part to which this table is appended. The specified style defines the appearance of the table in the output document, except for formats that are specified by the Style property of this Table object. The format objects specified by the Style property override formats defined by the stylesheet.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Horizontal alignment of table entries, specified as one of these values:

  • "center"

  • "left"

  • "right"

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Vertical alignment of table cell content, specified as one of these values:

  • "top"

  • "middle"

  • "bottom"

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Inner margin for the table entries, specified as a string scalar or character vector that consists of a number followed by an abbreviation of a unit of measurement. Valid abbreviations are:

  • px — pixels (default)

  • cm — centimeters

  • in — inches

  • mm — millimeters

  • pc — picas

  • pt — points

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Style to use for the table entries, specified as a cell array of format objects.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Tag for this DOM API object, 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.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Percentage of the page width, such as "100%", or a number of units of measurement, specified as a string scalar or character vector that consists of a number followed by an abbreviation of a unit of measurement. Valid abbreviations are:

  • px — pixels (default)

  • cm — centimeters

  • in — inches

  • mm — millimeters

  • pc — picas

  • pt — points

For Word report, the width is calculated as a percentage of the page width minus the margins.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Methods

expand all

Examples

collapse all

In this example, you create a table by using a Table object and specify its properties.

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

import mlreportgen.dom.*;

Create a Document object and open it.

d = Document("myreport","html");
open(d); 

Create a table object and specify its content by using a 5-by-5 MATLAB array. The number array is converted to a table of DOM objects of the same dimension.

t = Table(magic(5));

Specify the row height.

t.Style = {RowHeight("1in")};

Specify the width and style of row and column separators.

t.Border = "solid";
t.BorderWidth = "1px";
t.ColSep = "solid";
t.ColSepWidth = "1";
t.RowSep = "solid";
t.RowSepWidth = "1";

Set the style for the table entries.

t.TableEntriesStyle = [t.TableEntriesStyle {FontFamily("Arial"),Width("1in"),Color("red"),Bold}];

Set the horizontal and vertical alignment for the text in the table.

t.TableEntriesHAlign = "center";
t.TableEntriesVAlign = "middle";

Add the table to the document.

append(d,t);

Close the document and view the report.

close(d);
rptview(d);

Version History

Introduced in R2015b