Main Content

mlreportgen.report.BaseTable class

Package: mlreportgen.report
Superclasses: mlreportgen.report.Reporter

Create table reporter

Description

Use an object of the mlreportgen.report.BaseTable class to create a reporter for a table that has a title.

The mlreportgen.report.BaseTable class is a handle class.

Class Attributes

HandleCompatible
true

Creation

Description

table = mlreportgen.report.BaseTable() creates an empty table reporter. Use the reporter properties to specify the table content, title, style, and width.

example

table = mlreportgen.report.BaseTable(content) creates a table reporter and sets the Content property to content.

table = mlreportgen.report.BaseTable(Name,Value) sets properties using name-value pairs. You can specify multiple name-value pair arguments in any order. Enclose each property name in single or double quotes.

Properties

expand all

Table title, specified as one of these values:

  • String scalar or character vector

  • DOM object

  • 1-by-N or N-by-1 array of strings or DOM objects

  • 1-by-N or N-by-1 cell array of strings, character vectors, or DOM objects

  • Hole reporter returned by the getTitleReporter method

If the title value is inline content, which is content included in a paragraph, the table reporter uses a template stored in its template library to format the title. The template automatically numbers the table title using a format that depends on whether the table is in a numbered or unnumbered chapter.

  • A table in a numbered chapter has a title text prefix of the form "Table N.M" where N is the chapter number and M is the table number in the chapter. For example, the prefix for the third table in the second chapter of the report is Table 2.3.

  • A table in unnumbered chapter has a title text prefix of the form "Table N" where N is 1 for the first table in the report, 2 for the second table, and so on.

In many non-English locales, the title prefix is translated to the language and format of the locale. See the Locale property of mlreportgen.report.Report for a list of translated locales.

Attributes:

GetAccess
public
SetAccess
public

Table content, specified as one of these values:

  • mlreportgen.dom.Table object

  • mlreportgen.dom.FormalTable object

  • mlreportgen.dom.MATLABTable object

  • Two-dimensional array or cell array of DOM or built-in MATLAB® objects

  • Hole reporter returned by getContentReporter method

Use the BaseTable constructor or add method to set this property. You cannot set it directly.

Attributes:

GetAccess
public
SetAccess
public

Name of the style to apply to the table, specified as a string scalar or character vector. The specified style must be a table style defined in the template used by the report to which you append this table or in the template of a reporter added to the report.

If TableStyleName is empty, the table style is the default table style defined by the template of the reporter, which is a grid.

Attributes:

GetAccess
public
SetAccess
public

Width of this 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

Maximum number of columns to display per table slice, specified as Inf or as a positive integer. If the value of this property is Inf, all original table columns are included in a single table. A MaxCols value greater than or equal to the number of table columns also produces a single table with all columns. Large table data sets may be illegible.. Set this property to the number of columns from the original table that fit legibly on a page. To determine an optimal value, iterate setting the MaxCols value and viewing the report.

Attributes:

GetAccess
public
SetAccess
public

Number of initial columns to repeat per slice, specified as 0 or a positive integer. A nonzero number, n, repeats the first n columns of the original table in each slice. The MaxCols property value includes the RepeatCols property value. For example, if MaxCols is 6 and RepeatCols is 2, each table slice has a total of six columns with the first two columns repeated from the original table.

Attributes:

GetAccess
public
SetAccess
public

Name of the custom style to apply to the titles of table slices, specified as a string or a character vector.. The specified style must be defined in the report to which this reporter is added. If this property is empty ('', "", or []), the slice titles use the default style defined in the reporter template.

Attributes:

GetAccess
public
SetAccess
public

Source of the template for this reporter, specified in one of these ways:

  • Character vector or string scalar that specifies the path of the file that contains the template for this reporter

  • Reporter or report whose template is used for this reporter or whose template library contains the template for this reporter

  • DOM document or document part whose template is used for this reporter or whose template library contains the template for this reporter

The specified template must be the same type as the report to which this reporter is appended. For example, for a Microsoft® Word report, TemplateSrc must be a Word reporter template. If the TemplateSrc property is empty, this reporter uses the default reporter template for the output type of the report.

Attributes:

GetAccess
public
SetAccess
public

Name of the template for this reporter, specified as a character vector or string scalar. The template for this reporter must be in the template library of the template specified by the TemplateSrc property of this reporter.

Attributes:

GetAccess
public
SetAccess
public

Hyperlink target for this reporter, specified as a character vector or string scalar that specifies the link target ID, or an mlreportgen.dom.LinkTarget object. A character vector or string scalar value is converted to a LinkTarget object. The link target immediately precedes the content of this reporter in the output report.

Attributes:

GetAccess
public
SetAccess
public

Methods

expand all

Examples

collapse all

Add two tables that have titles to a report. The first table is a rank 5 magic square. The second table includes two images.

import mlreportgen.report.*
import mlreportgen.dom.*

rpt = Report("tables");
chapter = Chapter();
chapter.Title = "Table example";
add(rpt,chapter);

table = BaseTable(magic(5));
table.Title = "Rank 5 Magic Square";
add(rpt,table);

add(rpt,Paragraph());
imgSize = {Height("2in"),Width("2in")};
img1 = Image(which("b747.jpg"));
img1.Style = imgSize;
img2 = Image(which("peppers.png"));
img2.Style = imgSize;
table = BaseTable({"Boeing 747" "Peppers"; img1, img2});
table.Title = "Picture Gallery";
add(rpt,table);

delete(gcf);
rptview(rpt);

Introduced in R2017b