mlreportgen.dom.TableRow Class
Namespace: mlreportgen.dom
Table row
Description
Use objects of the mlreportgen.dom.TableRow
class to create a table
row.
The mlreportgen.dom.TableRow
class is a handle
class.
Class Attributes
ConstructOnLoad | true |
HandleCompatible | true |
For information on class attributes, see Class Attributes.
Creation
Description
creates an
empty table row.tableRowObj
= TableRow
Properties
Height
— Height of table row
[]
(default) | character vector | string scalar
Height of this table row, specified as a character vector or string
scalar that consists of a number followed by an abbreviation for a unit of
measurement. For example, '0.5in'
specifies one-half
inch. Valid abbreviations are:
"px"
— pixels"cm"
— centimeters"in"
— inches"mm"
— millimeters"pc"
— picas"pt"
— points
If the Style
property of this table row includes an
mlreportgen.dom.RowHeight
format object, the Height
property is set to the height
specified by the format object.
If you set the Height
property to a height value, a
RowHeight
object with the specified height is created and
added to the Style
property of the row, or is used to
replace an existing RowHeight
object in the
Style
property. The Type
of the
new RowHeight
object is 'exact'
. This
Type
value causes Microsoft® Word to generate a row of the specified height and truncate content
that does not fit. HTML and PDF viewers create a row of at least the
specified height and adjust the row height to accommodate the
content.
Note
If you add an mlreportgen.dom.Height
object to the Style
property, it is converted to an
mlreportgen.dom.RowHeight
object with the
Type
set to 'atleast'
. This
Type
value causes HTML and PDF viewers and
Microsoft Word to create a row of at least the specified height and
adjust the row height to accommodate the content.
Example: '0.5in'
Entries
— Table entries in row
array of mlreportgen.dom.TableEntry
objects
Table entries in this row, specified as an array of mlreportgen.dom.TableEntry
objects. Use this property to access the table entries in this row. For
example, this code accesses element 2 in row
2:
t = Table({'e11', 'e12'; 'e21', 'e22'}); elem22 = t.row(2).Entries(2);
You can also access element 2 in row 2 by using the entry
method of the mlreportgen.dom.Table
class.
For
example:
t = Table({'e11', 'e12'; 'e21', 'e22'}); elem22 = entry(t,2,2);
Once you access the TableEntry
object that corresponds
to a table entry, you can format the entry by setting properties of the
object. See Format a Table Entry.
This property is read-only.
NEntries
— Number of entries in row
0
(default) | integer
Number of table entries in this row, specified as an integer. This property is read-only.
StyleName
— Name of stylesheet-defined style
[]
(default) | character vector | string scalar
Style name, specified as a character vector or string scalar. The style name is the
name of a style specified in the style sheet of the document or document part to which
this element is appended. The specified style defines the appearance of this element in
the output document unless overridden by the formats specified by the
Style
property of this element. To learn more about using style
sheets, see Use Style Sheet Styles.
Note
Microsoft Word output ignores the style name.
Attributes:
NonCopyable | true |
Data Types: char
| string
Style
— Formats that define table row style
cell array of DOM format objects
Formats that define the style of this table row, 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.
You can specify the row height by adding an mlreportgen.dom.RowHeight
or
an mlreportgen.dom.Height
object to the Style
property. An
mlreportgen.dom.Height
object is converted to an
mlreportgen.dom.RowHeight
object with the type set to
'atleast'
.
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.TableRow
object
document element object
Parent of mlreportgen.dom.TableRow
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.TableRow
object
array of document element objects
Children of mlreportgen.dom.TableRow
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.TableRow
object
character vector | string scalar
Tag for the mlreportgen.dom.TableRow
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.TableRow
object
character vector | string scalar
Object identifier for the mlreportgen.dom.TableRow
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
Examples
Add Content to an Empty Table
To add content to an empty table, append table entries to table rows and then append the table rows to the table. This example creates this two-by-two table:
Create a document and then create a table that has two columns.
import mlreportgen.dom.*
d = Document();
t = Table(2);
Create two table rows.
tr1 = TableRow(); tr2 = TableRow();
Create table entries that contain the content and append the table entries to the rows.
append(tr1,TableEntry('e11')); append(tr1,TableEntry('e12')); append(tr2,TableEntry('e21')); append(tr2,TableEntry('e22'));
Append the table rows to the table.
append(t,tr1); append(t,tr2);
Append the table to the document. Close and view the document.
append(d,t); close(d); rptview(d);
Format a Table Entry
Use the Entries
property of an mlreportgen.dom.TableRow
object to access the mlreportgen.dom.TableEntry
object that corresponds to the entry that you want to format. Format the entry by setting format properties of the TableEntry
object or by adding format objects to the Style
property of the object. This example changes the text color of the second entry of the second row to red.
import mlreportgen.dom.* d = Document(); t = Table({'e11','e12';'e21','e22'}); t.row(2).Entries(2).Style = {Color('red')}; append(d,t); close(d); rptview(d);
In the resulting table, the text, e22
, in the second entry of the second row is red.
Alternatively, you can access a table entry by using the entry
method of the mlreportgen.dom.Table
object that contains the entry. In the previous example, replace:
t.row(2).Entries(2).Style = {Color('red')};
with:
elem = entry(t,2,2); elem.Style = {Color('red')};
Version History
Introduced in R2014b
MATLAB-Befehl
Sie haben auf einen Link geklickt, der diesem MATLAB-Befehl entspricht:
Führen Sie den Befehl durch Eingabe in das MATLAB-Befehlsfenster aus. Webbrowser unterstützen keine MATLAB-Befehle.
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)