mlreportgen.dom.FormalTable Class
Namespace: mlreportgen.dom
Formal table
Description
Defines a formal table, which is a table that has a body and optionally a table header, a
table footer, or both. The table header, body, and footer are
mlreportgen.dom.TableHeader
,
mlreportgen.dom.TableBody
, and
mlreportgen.dom.TableFooter
objects, respectively.
The mlreportgen.dom.FormalTable
class is a handle
class.
Creation
Description
creates an
empty formal table. Use this constructor as the starting point to create a formal table
from scratch.formalTableObj
= FormalTable
creates an empty formal table having the specified number of columns. formalTableObj
= FormalTable(ncols
)
creates a formal table with the body content specified. The constructor converts basic
MATLAB® types to corresponding DOM objects. For example, the constructor converts
character vectors to formalTableObj
= FormalTable(body
)mlreportgen.dom.Text
objects.
Note
Microsoft® Word automatically combines consecutive tables with matching style names into a single table. To render consecutive tables as separate tables in DOCX reports, do one of the following options:
Set the style names of the consecutive tables to different values.
Insert some content in between the tables. For example, insert an empty
mlreportgen.dom.Paragraph
element between the tables.
Input Arguments
ncols
— Number of columns in table
numeric value
Number of columns in a table, specified as a numeric value.
Data Types: double
body
— Table body content
two-dimensional numeric array | two-dimensional categorical array | two-dimensional cell array
Table body content, specified as:
A two-dimensional numeric array
A two-dimensional categorical array
A two-dimensional cell array that can contain:
Character vectors
One- or two-dimensional cell array
double
mlreportgen.dom.Text
objectmlreportgen.dom.Paragraph
objectmlreportgen.dom.Image
objectmlreportgen.dom.Table
objectmlreportgen.dom.FormalTable
objectmlreportgen.dom.OrderedList
objectmlreportgen.dom.UnorderedList
objectmlreportgen.dom.ExternalLink
objectmlreportgen.dom.InternalLink
objectmlreportgen.dom.CharEntity
object
styleName
— Style for table
character vector
The style specified by styleName
must be defined in the
template used to create the document that contains this table.
header
— Header content
two-dimensional numeric array | two-dimensional cell array of character vectors
The cell array may contain:
Character vectors
One- or two-dimensional cell array
double
mlreportgen.dom.Text
objectmlreportgen.dom.Paragraph
objectmlreportgen.dom.Image
objectmlreportgen.dom.Table
objectmlreportgen.dom.FormalTable
objectmlreportgen.dom.OrderedList
objectmlreportgen.dom.UnorderedList
objectmlreportgen.dom.ExternalLink
objectmlreportgen.dom.InternalLink
objectmlreportgen.dom.CharEntity
object
footer
— Footer content
two-dimensional numeric array | two-dimensional cell array of character vectors
The cell array may contain:
Character vectors
One- or two-dimensional cell array
double
mlreportgen.dom.Text
objectmlreportgen.dom.Paragraph
objectmlreportgen.dom.Image
objectmlreportgen.dom.Table
objectmlreportgen.dom.FormalTable
objectmlreportgen.dom.OrderedList
objectmlreportgen.dom.UnorderedList
objectmlreportgen.dom.ExternalLink
objectmlreportgen.dom.InternalLink
objectmlreportgen.dom.CharEntity
object
Properties
BackgroundColor
— Background color
[]
(default) | character vector | string scalar
Background color that consists of a CSS color name or a hexadecimal RGB value, specified as a character vector or string scalar.
For a list of CSS color names, see https://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:
NonCopyable | true |
Data Types: char
| string
Body
— Table body
mlreportgen.dom.TableBody
object
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:
SetAccess | protected |
NonCopyable | true |
Border
— Type of border to draw
"solid"
| "single"
| "dashed"
| "none"
| ... | ...
Type of border to draw, specified as one of the values in the table.
Border Value | Description | Supported Output Types |
---|---|---|
| Dashed line | HTML, PDF, Word |
| Line with alternating diagonal dashes and dot | Word |
| Dashed line with a small gap between dashes | Word |
| Dotted line | HTML, PDF, Word |
| Line with alternating dots and dashes | Word |
| Line with alternating double dots and a dash | Word |
| Double line | HTML, PDF, Word |
| Double wavy line | Word |
| 3-D effect grooved line | HTML, PDF |
| No line The | HTML, PDF |
| 3-D effect line | HTML, PDF, Word |
| No line The | HTML, PDF, Word |
| 3-D effect line | HTML, PDF, Word |
| 3-D effect ridged line | HTML, PDF |
| Single line | Word |
| Single line | HTML, PDF |
| Thick line | Word |
| Dashed line with alternating thick and thin dashes with a large gap | Word |
| Dashed line with alternating thick and thin dashes with a medium gap | Word |
| Dashed line with alternating thick and thin dashes with a small gap | Word |
| Dashed line with alternating thin and thick dashes with a medium gap | Word |
| Dashed line with alternating thin and thick dashes, with a medium gap | Word |
| Dashed line with alternating thin and thick dashes with a small gap | Word |
| Dashed line with alternating thin and thick dashes with a large gap | Word |
| Dashed line with alternating thin and thick dashes with a medium gap | Word |
| Dashed line with alternating thin and thick dashes with a small gap | Word |
| Embossed effect line | Word |
| Engraved effect line | Word |
| Triple line | Word |
| Wavy line | Word |
Attributes:
NonCopyable | true |
Data Types: char
| string
BorderCollapse
— Collapse borders of adjacent cells into single border (HTML only)
[] (determined by browser) | "on"
| "off"
A value of "on"
collapses borders of adjacent cells into a single border. A
value of "off"
keeps borders of adjacent cells.
Note
This property applies only to HTML documents.
Attributes:
NonCopyable | true |
Data Types: char
| string
BorderColor
— Border color
[]
(default) | character vector | string scalar
Border color, specified as a character vector or string scalar that consists
of a CSS color name (see https://www.w3.org/wiki/CSS/Properties/color/keywords) or a hexadecimal RGB (truecolor) value in the form
#RRGGBB
.
Example: "blue"
Example: "#0000ff"
Attributes:
NonCopyable | true |
Data Types: char
| string
BorderWidth
— Table border width
"px"
| "cm"
| "in"
| ...
Table border width, specified in the form valueUnits
, where
Units
is an abbreviation for the units. Valid abbreviations
are:
"px"
— pixels"cm"
— centimeters"in"
— inches"mm"
— millimeters"pc"
— picas"pt"
— points
Example: "2pt"
Attributes:
NonCopyable | true |
Data Types: char
| string
ColSep
— Style of line separating columns
"none"
| "solid"
| "dot"
| ...
Style of the line that separates the columns of a table or table
section, specified as a string scalar or a character vector. See the
Border
property for a table of valid entries.
Attributes:
NonCopyable | true |
Data Types: char
| string
ColSepColor
— Color of line separating columns
[]
(default) | character vector | string scalar
Color of lines separating columns specified as a character vector or string scalar that consists of a CSS color name or a hexadecimal RGB value.
For a list of CSS color names, see https://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:
NonCopyable | true |
Data Types: char
| string
ColSepWidth
— Width of line separating table columns
[]
(default) | character vector | string scalar
Width of the line separating table columns, specified as a character vector or string
scalar that consists of a number followed by an abbreviation of a unit of measurement.
Valid Units
abbreviations are:
"px"
— pixels"cm"
— centimeters"in"
— inches"mm"
— millimeters"pc"
— picas"pt"
— points
Example: "10pt"
Attributes:
NonCopyable | true |
Data Types: char
| string
ColSpecGroups
— Properties of group of columns in table
[]
(default) | array of mlreportgen.dom.TableColSpecGroup
objects
An array of mlreportgen.dom.TableColSpecGroup
objects
that specifies the width, alignment, and other properties of a group
of columns. 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 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:
NonCopyable | true |
FlowDirection
— Text flow direction
[]
(default) | "ltr"
| "rtl"
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:
NonCopyable | true |
Data Types: char
| string
Footer
— Footer for this table
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 via this property.
Attributes:
SetAccess | private |
Transient | true |
NonCopyable | true |
HAlign
— Horizontal alignment of this table
[]
(default) | "center"
| "left"
| "right"
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:
NonCopyable | true |
Data Types: char
| string
Header
— Table header
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 via this property.
Attributes:
SetAccess | private |
Transient | true |
NonCopyable | true |
isSortable
— Option to make table columns sortable (HTML only)
false
or 0
(default) | true
or 1
Since R2024a
Option to make table columns sortable, specified as a numeric or logical
1
(true
) or 0
(false
).
Attributes:
NonCopyable | true |
Data Types: logical
KeepWithinPage
— Whether table contents stay on same page
[]
(default) | true
or 1
| false
or 0
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:
NonCopyable | true |
Data Types: logical
OuterLeftMargin
— Left margin of table
[]
(default) | character vector | string scalar
Left margin of the table, specified as a character vector or string scalar that consists of 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"
Attributes:
NonCopyable | true |
Data Types: char
| string
RowSep
— Style of lines separating rows
[]
(default) | character vector | string scalar
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:
NonCopyable | true |
Data Types: char
| string
RowSepColor
— Color of lines separating table rows
[]
(default) | character vector | string scalar
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.
For a list of CSS color names, see https://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:
NonCopyable | true |
Data Types: char
| string
RowSepWidth
— Width of row separator
[]
(default) | character vector | string scalar
Width of the row separator, specified in the form valueUnits
where
Units
is an abbreviation for the units. Valid abbreviations
are:
"px"
— pixels"cm"
— centimeters"in"
— inches"mm"
— millimeters"pc"
— picas"pt"
— points
Example: "5pt"
Attributes:
NonCopyable | true |
Data Types: char
| string
TableEntriesStyle
— Style to use for table entries
[]
(default) | cell array of format objects
Style to use for the table entries, specified as a cell array of format objects.
Note
The styles specified by this property apply to the content of
a table's entries and not to the entries themselves. For
example, you can use this property to define the font size
of a table's entries but not the type or color of the entry
borders. To specify the borders, you have to set the
Style
property of each
entry.
Note
Be careful not to inadvertently overwrite a previous setting
of this property. For example, setting this table's
TableEntriesHAlign
property
appends an HAlign
format object to this
property. To avoid overwriting this property, you should set
this property before setting other table properties that
append formats to this property.
Attributes:
NonCopyable | true |
Data Types: cell
TableEntriesInnerMargin
— Inner margin for table entries
[]
(default) | character vector | string scalar
The inner margin is the margin between table cell content and the cell borders in the
form valueUnits
where Units
is an abbreviation for
the units. Valid abbreviations are:
"px"
— pixels"cm"
— centimeters"in"
— inches"mm"
— millimeters"pc"
— picas"pt"
— points
Attributes:
NonCopyable | true |
Data Types: char
| string
Width
— Table width
[]
(default) | character vector | string scalar
A percentage (for example, '100%'
) of the page width (minus margins
for Word reports) or a number of units of measurement, having the format
valueUnits
. Units
is an abbreviation for the
units. These are valid abbreviations:
px
— pixelscm
— centimetersin
— inchesmm
— millimeterspc
— picaspt
— points%
— percent
Example: "5pt"
Attributes:
NonCopyable | true |
Data Types: char
| string
StyleName
— Style in document or document part style sheet
[]
(default) | character vector | string scalar
Name of a style specified in the style sheet of the document or document part to which this table is appended
The style that specifies the appearance of this table in the output document, for
formats not specified by Style
property.
You can set the StyleName
property of any formal table section.
Setting StyleName
overrides the style specified by the formal table
itself.
Note
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 3x1 table.
Attributes:
NonCopyable | true |
Data Types: char
| string
Style
— Format specification
{}
(default) | array of DOM format objects
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:
NonCopyable | true |
CustomAttributes
— Custom attributes of document element
[]
(default) | array of mlreportgen.dom.CustomAttribute
objects
Custom attributes of this 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:
NonCopyable | true |
Parent
— Parent of mlreportgen.dom.FormalTable
object
document element object
Parent of mlreportgen.dom.FormalTable
object, specified as a document element
object. A document element must have only one parent.
Attributes:
SetAccess | private |
NonCopyable | true |
Children
— Children of mlreportgen.dom.FormalTable
object
array of document element objects
Children of mlreportgen.dom.FormalTable
object, specified as an array of document
element objects. This property contains the document element objects appended using the
append
method.
Attributes:
SetAccess | private |
NonCopyable | true |
Tag
— Tag for mlreportgen.dom.FormalTable
object
character vector | string scalar
Tag for the mlreportgen.dom.FormalTable
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
Id
— Object identifier for mlreportgen.dom.FormalTable
object
character vector | string scalar
Object identifier for the mlreportgen.dom.FormalTable
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
Methods
Public Methods
Method | Purpose |
---|---|
Use
| Append a row of table entries to table |
Append row to table footer | |
Append row to table header | |
Use
| Copy the table |
Version History
Introduced in R2014bR2024b: datetime
Array Display in Tables
datetime
arrays in mlreportgen.dom.Table
, mlreportgen.dom.FormalTable
, and mlreportgen.dom.MATLABTable
tables will now display as the point in time stored
in the array.
Before R2024b | Starting R2024b |
---|---|
|
|
R2024a: Sortable HTML Table Columns
Make HTML table columns sortable by using the using the isSortable
property in the mlreportgen.dom.FormalTable
class.
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)