This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

mlreportgen.report.BaseTable class

Package: mlreportgen.report
Superclasses:

Create table reporter

Description

Create a reporter for a table that includes a title.

Construction

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

table = BaseTable(content) creates a table reporter that formats the content as a table and adds it to a report.

table = 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 quotes.

Input Arguments

expand all

See the mlreportgen.dom.Table, FormalTable, or MATLABTable properties.

Properties

expand all

Table title, specified as one of these values:

  • String or character array

  • 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 arrays, and/or DOM objects

  • Hole reporter returned by the getTitleReporter method

Inline content is content that a paragraph can contain. If the title value is inline content, 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. ' 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.' 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.

Table content, specified as one of these values:

  • DOM Table object

  • DOM FormalTable object

  • DOM MATLAB® Table object

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

  • Hole reporter returned by getContentReporter method

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

Name of style to be applied to the table, specified as a string or character array. 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.

An empty TableStyleName property value specifies a default table style defined for the template of the reporter. The default style for the table is a grid.

Width of this table, specified as a string or character array. The TableWidth format is valueUnits, where Units is an abbreviation for the width units and value is the number of units. The table shows the valid Units abbreviations.

Units AbbreviationUnits
pxpixels
cmcentimeters
ininches
mmmillimeters
pcpicas
ptpoints
%percent

Example: 5in

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 can cause illegible tables to be generated. 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 MaxCol value and viewing the report.

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.

Name of the custom style to apply to the titles of table slices that this reporter generates. 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.

Source of template for this reporter, specified as one of these values:

  • String or character array specifying the path of the file containing the template for this reporter

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

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

The specified template must be of the same type as the report to which this reporter is appended. For example, for a 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.

Name of template for this reporter, specified as a string or character array. The template for this reporter is in the template library of the template source (TemplateSrc) for this reporter.

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

Methods

createTemplate Create table template
customizeReporterCreate custom base table reporter class
getClassFolder Base table class definition file location
getContentReporter Get base table content hole reporter
getTitleReporter Get base table title reporter

Inherited Methods

customizeReporterCreate class derived from Reporter class
getImpl Get implementation of reporter

Copy Semantics

Handle. To learn how handle classes affect copy operations, see Copying Objects (MATLAB).

Examples

Add Tables to a Report

Add two tables 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