Main Content

mlreportgen.dom.MATLABTable class

Package: 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

example

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

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

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

Table body, specified as an mlreportgen.dom.TableBody object. The table constructor creates a table body 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 by using this property.

Attributes:

GetAccess
public
SetAccess
private
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

Whether to collapse the borders of adjacent cells into a single border, specified as "on" or "off". 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 the line that separates 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 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

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

Footer for this table, specified as an mlreportgen.dom.TableFooter object. The table constructor creates a table footer 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 by using this property.

Attributes:

GetAccess
public
SetAccess
private
NonCopyable
true

Horizontal alignment of the 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

Table header, specified as an mlreportgen.dom.TableHeader object. . 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 by using this property.

Attributes:

GetAccess
public
SetAccess
private
NonCopyable
true

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

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

Number of columns, specified as an integer.

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

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

Style of the lines that separate the rows of the 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 the lines that separate 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 separate 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 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

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

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

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 followed by an abbreviation of a unit of measurement, specified as a string scalar or character vector. 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

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:

Introduced in R2016b