mlreportgen.report.BaseTable Class
Namespace: 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
creates an empty table reporter. Use the reporter properties to specify the
table content, title, style, and width.table
= mlreportgen.report.BaseTable
creates a table reporter and sets the table
= mlreportgen.report.BaseTable(content
)Content
property to content
.
sets properties using name-value pairs. You can specify multiple name-value pair
arguments in any order.table
= mlreportgen.report.BaseTable(Name=Value
)
Properties
Title
— Table title
character vector | string scalar | ...
Table title, specified as one of these values:
String scalar or character vector
DOM element object
1-by-N or N-by-1 array of strings or DOM element objects
1-by-N or N-by-1 cell array of strings, character vectors, or DOM element 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.
Content
— Table content
mlreportgen.dom.Table
object | mlreportgen.dom.FormalTable
object | mlreportgen.dom.MATLABTable
object | ...
Table content, specified as one of these values:
mlreportgen.dom.Table
objectmlreportgen.dom.FormalTable
objectmlreportgen.dom.MATLABTable
objectTwo-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.
TableStyleName
— Style to apply to table
character vector | string scalar
Name of the style to apply to the table, specified as a character vector or string scalar. 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.
Data Types: char
| string
TableWidth
— Width of the table
[]
| character vector | string scalar
Width of this 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
Data Types: char
| string
MaxCols
— Maximum number of columns to display per table slice
Inf
(default) | positive integer
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.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
RepeatCols
— Number of initial columns to repeat per slice
0 (default) | positive integer
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.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
TableSliceTitleStyleName
— Name of style applied to sliced table title
[]
(default) | character vector | string scalar
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.
Data Types: char
| string
TableEntryUpdateFcn
— Update table entries callback
[]
(default) | function handle
Update table entries callback, specified as a function handle. The
callback function accepts an mlreportgen.dom.TableEntry
object as the input argument. Appending the BaseTable
object
to a report triggers the callback function once for each table entry before
the table is appended to the report. Use this function to customize the
appearance of table entries based on the content of the entries. For
example, see Customize Table Entries by Content in a PDF Report.
Attributes:
GetAccess | public |
SetAccess | public |
TemplateSrc
— Source of template for reporter
[]
(default) | character vector | string scalar | reporter or report | DOM document or document part
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 you
append this report. 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.
TemplateName
— Name of template for this reporter
character vector | string scalar
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.
Data Types: char
| string
LinkTarget
— Hyperlink target for this reporter
[]
(default) | character vector | string scalar | mlreportgen.dom.LinkTarget
object
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 converts to a LinkTarget
object. The link target immediately
precedes the content of this reporter in the output report.
Methods
Public Methods
Method | Purpose |
---|---|
mlreportgen.report.BaseTable.createTemplate | Create table template |
mlreportgen.report.BaseTable.customizeReporter | Create custom base table reporter class |
mlreportgen.report.BaseTable.getClassFolder | Get base table class definition file location |
getContentReporter | Get base table content hole reporter |
getTitleReporter | Get base table title reporter |
getImpl | Get implementation of reporter |
copy | Create copy of reporter object and make deep copies of property
values that reference a reporter, ReporterLayout , or
DOM element object |
Examples
Add Tables with Titles to a Report
Add two tables that have titles to a report. The first table is a rank 5 magic square. The second table includes two images.
Run the following command to access the supporting files used in this example.
openExample('rptgen/MatlabReportGeneratorSupportFilesExample');
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);
Customize Table Entries by Content in a PDF Report
This example shows how to customize table entries, based on the content of the entries when using an mlreportgen.report.BaseTable
reporter. You can run this example only on MATLAB version R2022a or later.
Import these packages, so that you do not have to use long, fully qualified class names.
import mlreportgen.dom.* import mlreportgen.report.*
Create a table with student names and grades.
Student_names = ["Charlie","Sarah","John","Teena","Alfred","Emma","Bill","Tyler"]'; Student_grades = [83,42,75,98,78,49,91,88]'; studentsTable = FormalTable(["Student Name","Student Grade"],[Student_names,Student_grades]); studentsTable.Header.Style{end+1} = BackgroundColor("silver"); studentsTable.Width = "250pt";
Create an mlreportgen.dom.BaseTable
reporter with the students table.
baseTabReporter = BaseTable(studentsTable);
Assign a handle of the callback function tabEntryUpdateCB
, that is defined in the file tabEntryUpdateCB.mlx
, to the TableEntryUpdateFcn
property of the reporter.
Use the command edit tabEntryUpdateCB
in the command line to see the code of the callback function.
baseTabReporter.TableEntryUpdateFcn = @tabEntryUpdateCB;
Create an mlreportgen.dom.Report
of type PDF, then append the base table reporter to the report.
document = Report("Update_table_entries_example_report","pdf"); append(document,baseTabReporter);
Close and view the report.
close(document); rptview(document);
Version History
Introduced in R2017b
MATLAB 명령
다음 MATLAB 명령에 해당하는 링크를 클릭했습니다.
명령을 실행하려면 MATLAB 명령 창에 입력하십시오. 웹 브라우저는 MATLAB 명령을 지원하지 않습니다.
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)