Package: mlreportgen.dom
Superclasses:
Create table
Use an mlreportgen.dom.Table
object to define
a table. Append rows and table entries to add content to the table.
You can define column properties.
creates
an empty table having the specified number of columns. Use this constructor
as the starting point for creating a table from scratch.tableObj
= Table(nCols
)
returns
a table whose content is specified by an array. The constructor converts
basic MATLAB® types to corresponding DOM types, e.g., character
vectors to Text objects.tableObj
= Table(array
)
creates
a table having the specified style. The style specified by tableObj
= Table(array
,style
)style
must
be defined in the template used to create the document to which this
table is appended.
nCols
— Number of table columnsNumber of table columns, specified as a double.
Data Types: double
array
— Table body contentTable 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
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
style
— Style for tableStyle for table, specified as a character vector. The specified style must be defined in the template used by the document you append this table to.
tableObj
— Tablemlreportgen.dom.Table
objectTable, represented by an mlreportgen.dom.Table
object.
BackgroundColor
— Background color[]
(default) | character vector | string scalarBackground color, specified as a character vector or string scalar that
consists of a CSS color name (see https://www.crockford.com/wrrrld/color.html) or a
hexadecimal RGB (truecolor) value in the form
#RRGGBB
.
Setting the BackgroundColor
property adds a corresponding
mlreportgen.dom.BackgroundColor
format object to the
Style
property. Setting the
BackgroundColor
property to an empty value
removes the object.
Example: 'blue'
Example: '#0000ff'
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 | All output types |
| Line with alternating diagonal dashes and dot | Word |
| Dashed line with a small gap between dashes | Word |
| Dotted line | All output types |
| Line with alternating dots and dashes | Word |
| Line with alternating double dots and a dash | Word |
| Double line | All output types |
| Double wavy line | Word |
| 3-D effect grooved line | HTML and PDF |
| No line The | HTML and PDF |
| 3-D effect line | All output types |
| No line The | All output types |
| 3-D effect line | All output types |
| 3-D effect ridged line | HTML and PDF |
| Single line | Word |
| Single line | HTML and 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 |
BorderCollapse
— Collapse borders of adjacent cells into single border (HTML only)'on'
| 'off'
A value of 'on'
collapses borders of adjacent
cells into a single border. A value of 'off'
keeps
borders of adjacent cells.
BorderColor
— Border colorBorder color, specified as either:
Name of a color. The name must be a CSS color name. See https://www.crockford.com/wrrrld/color.html.
A hexadecimal RGB (truecolor) value as #RRGGBB
.
For example, #0000ff
is a shade of blue.
BorderWidth
— Table border widthTable border width, specified in the form valueUnits
,
where Units
is an abbreviation for the units. Valid
abbreviations are:
px
— pixels (default)
cm
— centimeters
in
— inches
mm
— millimeters
pc
— picas
pt
— points
Children
— Children of document elementChildren of this document element, specified as an array of DOM objects. This property is read-only.
ColSep
— Style of line separating columnsThe style of the line separating the columns of a table or table section (header, body,
footer), as specified by an mlreportgen.dom.ColSep
object.
See the description of the Border
property
for a description of the possible values.
ColSepColor
— Color of line separating columnsColor of line separating columns, specified as either:
Name of a color. The name must be a CSS color name. See https://www.crockford.com/wrrrld/color.html.
A hexadecimal RGB (truecolor) value as #RRGGBB
.
For example, #0000ff
is a shade of blue.
ColSepWidth
— Width of line separating table columnsWidth of the line separating table columns, in the form valueUnits
.
Use one of these abbreviations for the Units
:
px
— pixels (default)
cm
— centimeters
in
— inches
mm
— millimeters
pc
— picas
pt
— points
For example, for a column separator of 3 points, set the ColSepWidth
property
to '3pt'
.
ColSpecGroups
— Properties of group of columns in tablemlreportgen.dom.TableColSpecGroup
objectsAn 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.
CustomAttributes
— Custom attributes for document elementmlreportgen.doc.CustomAttribute
objectsThe custom attributes must be supported by the output type of the document to which this document element is appended.
FlowDirection
— Text flow direction'ltr'
| 'rtl'
Direction for text to flow, specified as one of these values:
'ltr'
— flow from left to
right
'rtl'
— flow from right
to left
HAlign
— Horizontal alignment of this table'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.
Id
— ID for this document elementID for this document element, 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.
NCols
— Number of columns in this tableNumber of table columns, specified as an integer. This property is
read-only. 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 is updated. 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.
NRows
— Number of rows in this tableNumber of rows in this table, specified as an integer. This property is
read-only. 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 is updated.
OuterLeftMargin
— Left margin (indentation) of document elementLeft indentation in the form valueUnits
. Units
is
an abbreviation for the units. Valid abbreviations are:
px
— pixels (default)
cm
— centimeters
in
— inches
mm
— millimeters
pc
— picas
pt
— points
Parent
— Parent of document elementParent of this document element, specified as a DOM object. This property is read-only.
RowSep
— Style of lines separating rowsThe style of a line separating the rows of a table or table section (header, body, or footer).
See the description of the Border
property
for a description of the possible values.
RowSepColor
— Color of lines separating table rowsColor of lines separating table rows, specified as one of these values:
The name of a color. See the mlreportGen.dom.Color
class
reference page for a list of supported colors.
A hexadecimal RGB (truecolor) value as #RRGGBB
.
For example, #0000ff
is a shade of blue.
RowSepWidth
— Width of lines separating table rowsWidth of lines separating table rows in the form valueUnits
,
where Units
is an abbreviation for the units. Use
one of these abbreviations:
px
— pixels (default)
cm
— centimeters
in
— inches
mm
— millimeters
pc
— picas
pt
— points
Style
— Format for tableArray of format objects (such as Bold
objects)
that specify the format for this table.
This property overrides corresponding formats defined by the
style sheet style specified by the StyleName
property.
StyleName
— Style in document or document part style sheetName 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.
TableEntriesHAlign
— Horizontal alignment of table entries'center'
(default) | 'left'
| 'right'
Horizontal alignment of table entries, specified as one of these values:
'center'
'left'
'right'
Data Types: char
TableEntriesVAlign
— Vertical alignment of table cell content'top'
| 'middle'
| 'bottom'
Vertical alignment of table cell content, specified as one of these values:
'top'
'middle'
'bottom'
TableEntriesInnerMargin
— Inner margin for table entriesThe 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 (default)
cm
— centimeters
in
— inches
mm
— millimeters
pc
— picas
pt
— points
TableEntriesStyle
— Style to use for table entriesCell array of format objects that specify the format for table entries.
Tag
— Tag for this document elementTag for this document element, 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.
Width
— Table widthA 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
— pixels (default)
cm
— centimeters
in
— inches
mm
— millimeters
pc
— picas
pt
— points
import mlreportgen.dom.*; d = Document('myreport','html'); open(d); t = Table(magic(5)); t.Style = {RowHeight('1in')}; t.Border = 'solid'; t.BorderWidth = '1px'; t.ColSep = 'solid'; t.ColSepWidth = '1'; t.RowSep = 'solid'; t.RowSepWidth = '1'; % Set this property first to prevent overwriting alignment properties t.TableEntriesStyle = {FontFamily('Arial'),Width('1in'),Color('red'),Bold}; t.TableEntriesHAlign = 'center'; t.TableEntriesVAlign = 'middle'; append(d,t); close(d); rptview(d.OutputPath);
You have a modified version of this example. Do you want to open this example with your edits?