Main Content

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

选择要创建的表类型

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

表类型示例(PDF 格式)更多信息
正式表格 - 具有不同格式的表头、正文和表脚部分的表格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 表 (mlreportgen.dom.MATLABTable) 的 DOM 表示

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

基表

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

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

基表

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

另请参阅

| | |

相关主题