Main Content

mlreportgen.dom.MATLABTable Class

Namespace: mlreportgen.dom
Superclasses: mlreportgen.dom.FormalTable

MATLAB table

Description

Use an object of the mlreportgen.dom.MATLABTable class to convert a MATLAB® table to a DOM table.

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

Class Attributes

HandleCompatible
true
ConstructOnLoad
true

Creation

Description

MLTableObj = mlreportgen.dom.MATLABTable(table) creates a table object based on the specified MATLAB table.

example

MLTableObj = mlreportgen.dom.MATLABTable(table,stylename) creates the table object and sets the StyleName property to stylename. Define the style in the template used to generate the report containing this table.

Input Arguments

expand all

MATLAB table, used to generate the DOM table, specified as a MATLAB table.

Properties

expand all

Background color that contains a CSS color name or a hexadecimal RGB value, specified as a character vector or string scalar.

  • To use the name of a color, specify a CSS color name. For a list of CSS color names, seehttps://www.w3.org/wiki/CSS/Properties/color/keywords.

  • To specify a hexadecimal RGB format, use # as the first character and two-digit hexadecimal numbers for the red, green, and blue values. For example, "#0000ff" specifies blue.

Note

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

Data Types: char | string

The table constructor creates a mlreportgen.dom.TableBody object and assigns it to this property when the formal table is constructed. You cannot subsequently set this property. However, you can append content to the table body and set its properties via this property.

Attributes:

GetAccess
public
SetAccess
private
Transient
true
NonCopyable
true

Type of border to draw, specified as one of these values:

Border StyleDescriptionSupported in Microsoft® WordSupported in HTML and PDF
"dashed"Dashed lineyesyes
"dashdotstroked"Line with alternating diagonal dashes and dotyesyes
"dashsmallgap"Dashed line with a small gap between dashesyesyes
"dotted"Dotted lineyesyes
"dotdash"Line with alternating dots and dashesyesno
"dotdotdash"Line with alternating double dots and a dashyesno
"double"Double lineyesyes
"doublewave"Double wavy lineyesno
"groove"3-D effect grooved linenoyes
"hidden"

No line

When there is a conflicting border style, the "hidden" border style takes precedence over the conflicting border style, which results in no line displaying.

noyes
"inset"3-D effect linenoyes
"none"

No line

When there is a conflicting border style, the conflicting border style takes precedence over "none", which results in the conflicting border style displaying.

yesyes
"outset"3-D effect lineyesyes
"ridge"3-D effect ridged linenoyes
"single"Single lineyesyes
"solid"Single linenoyes
"thick"Thick lineyesno
"thickthinlargegap"Dashed line with alternating thick and thin dashes with a large gapyesno
"thickthinmediumgap"Dashed line with alternating thick and thin dashes with a medium gapyesno
"thickthinsmallgap"Dashed line with alternating thick and thin dashes with a small gapyesno
"thinthicklargegap"Dashed line with alternating thin and thick dashes with a large gapyesno
"thinthickmediumgap"Dashed line with alternating thin and thick dashes with a medium gapyesno
"thinthicksmallgap"Dashed line with alternating thin and thick dashes with a small gapyesno
"thinthickthinlargegap"Dashed line with alternating thin and thick dashes with a large gapyesno
"thinthickthinmediumgap"Dashed line with alternating thin and thick dashes with a medium gapyesno
"thinthickthinsmallgap"Dashed line with alternating thin and thick dashes with a small gapyesno
"threedemboss"Embossed effect lineyesno
"threedengrave"Engraved effect lineyesno
"triple"Triple lineyesno
"wave"Wavy lineyesno

Note

For Microsoft Word reports, when you assign an mlreportgen.dom.Border object to the Style property of an mlreportgen.dom.TableHeaderEntry, mlreportgen.dom.TableEntry, or mlreportgen.dom.HorizontalRule object, the reporter does not support "inset" or "outset" styles for this property.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Whether to collapse borders of adjacent cells into a single border, specified as:

  • "on" — Collapses borders of adjacent cells into a single border

  • "off" — Keeps the borders of adjacent cells

Note

This property applies only to HTML documents.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Data Types: char | string

Color of the border, specified as a character vector or string scalar that contains a CSS color name or hexadecimal RGB value.

  • To use the name of a color, specify a CSS color name. For a list of CSS color names, seehttps://www.w3.org/wiki/CSS/Properties/color/keywords.

  • To specify a hexadecimal RGB format, use # as the first character and two-digit hexadecimal numbers for the red, green, and blue values. For example, "#0000ff" specifies blue.

Example: "blue"

Example: "#0000ff"

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Data Types: char | string

Table border width, specified as character vector or string scalar that contains a number followed by an abbreviation for a unit of measurement. For example, "10px" specifies 10 pixels. Valid abbreviations are:

  • "px" — Pixels

  • "cm" — Centimeters

  • "in" — Inches

  • "mm" — Millimeters

  • "pc" — Picas

  • "pt" — Points

Example: "2pt"

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Data Types: char | string

Style of the line that separates the columns of a table or table section, specified as one of these values:

Border StyleDescriptionSupported in Microsoft WordSupported in HTML and PDF
"dashed"Dashed lineyesyes
"dashdotstroked"Line with alternating diagonal dashes and dotyesyes
"dashsmallgap"Dashed line with a small gap between dashesyesyes
"dotted"Dotted lineyesyes
"dotdash"Line with alternating dots and dashesyesno
"dotdotdash"Line with alternating double dots and a dashyesno
"double"Double lineyesyes
"doublewave"Double wavy lineyesno
"groove"3-D effect grooved linenoyes
"hidden"

No line

When there is a conflicting border style, the "hidden" border style takes precedence over the conflicting border style, which results in no line displaying.

noyes
"inset"3-D effect linenoyes
"none"

No line

When there is a conflicting border style, the conflicting border style takes precedence over "none", which results in the conflicting border style displaying.

yesyes
"outset"3-D effect lineyesyes
"ridge"3-D effect ridged linenoyes
"single"Single lineyesyes
"solid"Single linenoyes
"thick"Thick lineyesno
"thickthinlargegap"Dashed line with alternating thick and thin dashes with a large gapyesno
"thickthinmediumgap"Dashed line with alternating thick and thin dashes with a medium gapyesno
"thickthinsmallgap"Dashed line with alternating thick and thin dashes with a small gapyesno
"thinthicklargegap"Dashed line with alternating thin and thick dashes with a large gapyesno
"thinthickmediumgap"Dashed line with alternating thin and thick dashes with a medium gapyesno
"thinthicksmallgap"Dashed line with alternating thin and thick dashes with a small gapyesno
"thinthickthinlargegap"Dashed line with alternating thin and thick dashes with a large gapyesno
"thinthickthinmediumgap"Dashed line with alternating thin and thick dashes with a medium gapyesno
"thinthickthinsmallgap"Dashed line with alternating thin and thick dashes with a small gapyesno
"threedemboss"Embossed effect lineyesno
"threedengrave"Engraved effect lineyesno
"triple"Triple lineyesno
"wave"Wavy lineyesno

Note

For Microsoft Word reports, when you assign an mlreportgen.dom.Border object to the Style property of an mlreportgen.dom.TableHeaderEntry, mlreportgen.dom.TableEntry, or mlreportgen.dom.HorizontalRule object, the reporter does not support "inset" or "outset" styles for this property.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Data Types: char | string

Color of the lines that separate the columns, specified as a character vector or string scalar that contains a CSS color name or a hexadecimal RGB value.

  • To use the name of a color, specify a CSS color name. For a list of CSS color names, seehttps://www.w3.org/wiki/CSS/Properties/color/keywords.

  • To specify a hexadecimal RGB format, use # as the first character and two-digit hexadecimal numbers for the red, green, and blue values. For example, "#0000ff" specifies blue.

Example: "blue"

Example: "#0000ff"

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Data Types: char | string

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

  • "px" — Pixels

  • "cm" — Centimeters

  • "in" — Inches

  • "mm" — Millimeters

  • "pc" — Picas

  • "pt" — Points

Example: "10pt" specifies 10 points

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Data Types: char | string

Properties of group of columns in the table, 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 that belong 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

Text flow direction, 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

Data Types: char | string

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

  • "center"

  • "left"

  • "right"

Note

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

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Data Types: char | string

The table constructor creates a table header object and assigns it to this property when the formal table is constructed. You cannot subsequently set this property. However, you can append content to the table body and set its properties via this property.

Attributes:

GetAccess
public
SetAccess
private
Transient
true
NonCopyable
true

Horizontal rule for the heading, specified as an mlreportgen.dom.HorizontalRule object.

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 columns, specified as an integer.

Attributes:

SetAccess
private
NonCopyable
true

Data Types: uint64

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

  • "px" — Pixels

  • "cm" — Centimeters

  • "in" — Inches

  • "mm" — Millimeters

  • "pc" — Picas

  • "pt" — Points

Example: "10pt" specifies 10 points

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Data Types: char | string

Whether to enable the first column that contains the row names, specified as logical. The MATLAB table object must define the row names.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Data Types: logical

Style of the lines that separate the rows of a table or table section, specified as one of these values:

Border StyleDescriptionSupported in Microsoft WordSupported in HTML and PDF
"dashed"Dashed lineyesyes
"dashdotstroked"Line with alternating diagonal dashes and dotyesyes
"dashsmallgap"Dashed line with a small gap between dashesyesyes
"dotted"Dotted lineyesyes
"dotdash"Line with alternating dots and dashesyesno
"dotdotdash"Line with alternating double dots and a dashyesno
"double"Double lineyesyes
"doublewave"Double wavy lineyesno
"groove"3-D effect grooved linenoyes
"hidden"

No line

When there is a conflicting border style, the "hidden" border style takes precedence over the conflicting border style, which results in no line displaying.

noyes
"inset"3-D effect linenoyes
"none"

No line

When there is a conflicting border style, the conflicting border style takes precedence over "none", which results in the conflicting border style displaying.

yesyes
"outset"3-D effect lineyesyes
"ridge"3-D effect ridged linenoyes
"single"Single lineyesyes
"solid"Single linenoyes
"thick"Thick lineyesno
"thickthinlargegap"Dashed line with alternating thick and thin dashes with a large gapyesno
"thickthinmediumgap"Dashed line with alternating thick and thin dashes with a medium gapyesno
"thickthinsmallgap"Dashed line with alternating thick and thin dashes with a small gapyesno
"thinthicklargegap"Dashed line with alternating thin and thick dashes with a large gapyesno
"thinthickmediumgap"Dashed line with alternating thin and thick dashes with a medium gapyesno
"thinthicksmallgap"Dashed line with alternating thin and thick dashes with a small gapyesno
"thinthickthinlargegap"Dashed line with alternating thin and thick dashes with a large gapyesno
"thinthickthinmediumgap"Dashed line with alternating thin and thick dashes with a medium gapyesno
"thinthickthinsmallgap"Dashed line with alternating thin and thick dashes with a small gapyesno
"threedemboss"Embossed effect lineyesno
"threedengrave"Engraved effect lineyesno
"triple"Triple lineyesno
"wave"Wavy lineyesno

Note

For Microsoft Word reports, when you assign an mlreportgen.dom.Border object to the Style property of an mlreportgen.dom.TableHeaderEntry, mlreportgen.dom.TableEntry, or mlreportgen.dom.HorizontalRule object, the reporter does not support "inset" or "outset" styles for this property.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Data Types: char | string

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

  • To use the name of a color, specify a CSS color name. For a list of CSS color names, seehttps://www.w3.org/wiki/CSS/Properties/color/keywords.

  • To specify a hexadecimal RGB format, use # as the first character and two-digit hexadecimal numbers for the red, green, and blue values. For example, "#0000ff" specifies blue.

Example: "blue"

Example: "#0000ff"

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Data Types: char | string

Width of the row separator, specified as character vector or string scalar that contains a number followed by an abbreviation for a unit of measurement. For example, "10px" specifies 10 pixels. Valid abbreviations are:

  • "px" — Pixels

  • "cm" — Centimeters

  • "in" — Inches

  • "mm" — Millimeters

  • "pc" — Picas

  • "pt" — Points

Example: "5pt"

Attributes:

NonCopyable
true

Data Types: char | string

Table width, specified as a character vector or string scalar that contains a number followed by an abbreviation for a unit of measurement. For example, "100%" specifies 100% of the page width in a PDF report, and 100% of the page width, minus the margins, for a Word report. Valid abbreviations are::

  • px — Pixels

  • cm — Centimeters

  • in — Inches

  • mm — Millimeters

  • pc — Picas

  • pt — Points

  • % — Percent

Example: "5pt" specifies five points

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Data Types: char | string

Style to use for the table entries, specified as a cell array of format objects. The styles specified by this property apply to the content of the table entries and not to the entries themselves. For example, you can use this property to define the font size of the table entries but not the type or color of the entry borders. To specify the borders, set the Style property of each entry.

Note

Be careful not to inadvertently overwrite a previous setting of this property. For example, setting the table TableEntriesHAlign property appends an HAlign format object to this property. To avoid overwriting this property, set this property before setting other table properties that append formats to this property.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Data Types: cell

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

  • "px" — Pixels

  • "cm" — Centimeters

  • "in" — Inches

  • "mm" — Millimeters

  • "pc" — Picas

  • "pt" — Points

Example: "10px" specifies 10 pixels

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Data Types: char | string

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 MATLABTable object. The format objects specified by the Style property override formats defined by the stylesheet.

You can set the StyleName property of any formal table section. Setting StyleName overrides the style specified by the formal table itself. However, if you do this for a Word document, you must explicitly specify the width of each column in a section to ensure that all sections have the same width. Word, unlike HTML and PDF, has no built-in support for formal tables. To handle this, the DOM interface represents a formal table as three tables, one for each section, embedded in a 3-by-1 table.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Data Types: char | string

Format specification for this document element object, specified as an array of DOM format objects. The formats specified by this property override corresponding formats specified by the StyleName property of this element. Formats that do not apply to this document element object are ignored.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

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

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Parent of this object, specified as a document element object. A document element must have only one parent.

Attributes:

GetAccess
public
SetAccess
private
NonCopyable
true

Children of this object, specified as an array of document element objects. This property contains the document element objects appended using the append method.

Attributes:

GetAccess
public
SetAccess
private
NonCopyable
true

Tag, 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. Use this value to help identify where an issue occurs during document generation.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Data Types: char | string

Object identifier, specified as a character vector or string scalar. The DOM API generates a session-unique identifier when it creates the document element object.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Data Types: char | string

Methods

expand all

Examples

collapse all

This example creates a DOM table from a MATLAB table that has row names. The example generates two reports that include the DOM table. In the first report, the row names column of the table does not have a label. In the second report, the row names column has a label.

Create a MATLAB table that shows the age, weight, and height of patients. Use the RowNames option to identify each row by the last name of the patient.

LastName = {'Sanchez';'Johnson';'Lee';'Diaz';'Brown'};
Age = [38;43;38;40;49];
Weight = [176;163;131;133;119];
Height = [71;69;64;67;64];
mltable = table(Age,Weight,Height,'RowNames',LastName)
mltable=5×3 table
               Age    Weight    Height
               ___    ______    ______

    Sanchez    38      176        71  
    Johnson    43      163        69  
    Lee        38      131        64  
    Diaz       40      133        67  
    Brown      49      119        64  

The MATLAB table has five rows and three columns. The row names are not part of the table. They are stored in a property of the table.

Create an mlreportgen.dom.MATLABTable object from the MATLAB table.

import mlreportgen.dom.*
mltableObj = MATLABTable(mltable);

Create a document and append the MATLABTable object to the document. Close and view the document.

d = Document('MyMATLABTable1','docx');
append(d,mltableObj);
close(d);
rptview(d);

Here is the table in the generated report:

The DOM table is a formal table, which has a header and a body. The table body has five rows and four columns. The first column consists of the MATLAB table row names.

Generate the report again, this time with a label for the column of row names. To specify the label, replace the empty text in the first entry of the table header row with the label text. To draw a line under the label, set the RowNamesRule property of the MATLABTable object to true.

LastName = {'Sanchez';'Johnson';'Lee';'Diaz';'Brown'};
Age = [38;43;38;40;49];
Weight = [176;163;131;133;119];
Height = [71;69;64;67;64];
mltable = table(Age,Weight,Height,'RowNames',LastName);
import mlreportgen.dom.*
mltableObj = MATLABTable(mltable);
th = mltableObj.Header;
thentry11 = entry(th,1,1);
thentry11.Children(1).Children(1).Content = 'Names';
mltableObj.RowNamesRule = true;
d = Document('MyMATLABTable2','docx');
append(d,mltableObj);
close(d);
rptview(d);

Here is the table in the generated report:

Version History

Introduced in R2016b

expand all