主要内容

本页采用了机器翻译。点击此处可查看最新英文版本。

在报告生成器中选择要创建的表类型

您可以使用 DOM API 和报告 API 在报告中创建四种类型的表。不同类型的表具有不同的结构,并由不同的类来表示。

表类型示例更多信息
正式表 - 具有不同格式的表头、正文和表脚部分的表mlreportgen.dom.FormalTable

Table with the column names "Age", "Weight", "Height". The background of the header is light steel blue. The table body has three rows and three columns of numbers that represent patient age, weight, and height.

创建正式表
非正式表 - 仅包含主体的表mlreportgen.dom.Table

Three-by-three table of numbers representing patient age, height, and weight. The border and separators are thin, solid, and black.

创建非正式表
MATLAB® 表 - 由 MATLAB 表构建的表mlreportgen.dom.MATLABTable

Table with named rows and a header of column names. The text in the header and first column is bold. The table body has three rows containing the patient name, age, weight, and height. The table has the appearance of a table in MATLAB.

从 MATLAB 表创建表
基表 - 带有编号标题的表mlreportgen.report.BaseTable

Table with the title "Table 1. Patient Data".

创建报告 API 基表

根据您的表需求选择要创建的表类型。在某些情况下,可能有多种类型的表符合您的要求,请根据您的预设项选择表类型。

需求表类型

创建带有页眉或页脚的表。

  • 如果页眉或页脚包含多行内容,请使用正式的表。独立的页眉、正文和页脚部分使添加内容以及格式化页眉、正文或页脚变得更加轻松。

  • 如果表头只有一行,请使用非正式或正式的表。您可以将非正式表的第一行格式化为标题。

创建一个没有页眉或页脚的表。

非正式表

将 MATLAB 表转换为 DOM 表。

MATLAB 表

创建一个带有编号标题的表。

基表

您可以创建一个 DOM 表,然后从 DOM 表创建基础表,或者直接从 MATLAB 数组创建基础表。

将宽表分成清晰易读的部分。

基表

如果 DOM 表太宽,可以从 DOM 表创建一个基表,然后使用 BaseTable 属性将表切片。您还可以使用 mlreportgen.utils.TableSlicer 对作为 TableFormalTable 对象创建的表进行切分。

创建一个带有可折叠行和列的 HTML 表。 (自 R2025a 起)

  • 非正式会议。有关详细信息,请参阅创建可折叠行 HTML 表

  • 正式表或 MATLAB 表。您只能折叠 TableHeaderTableBodyTableFooter 部分中的行。

另请参阅

主题