Main Content

Choose Type of Table to Create

You can use the DOM API and Report API to create four types of tables in your reports. The types of tables have different structures and are represented by different classes.

Type of TableClassExample (in PDF)More Information
Formal table — A table with differently formatted header, body, and footer sectionsmlreportgen.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.

Create Formal Tables
Informal table — A table that has only a bodymlreportgen.dom.Table

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

Create Informal Tables
MATLAB® table — A table constructed from a MATLAB tablemlreportgen.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.

Create Tables from MATLAB Tables
Base table — A table with a numbered titlemlreportgen.report.BaseTable

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

Create Report API Base Tables

The following guidelines help you choose the type of table to create based on your table requirements. The guidelines are not exhaustive. In some cases, more than one type of table might meet your requirements. In these cases, you can choose the type of table based on your preferences.

RequirementType of Table

Create a table with a header or footer.

  • Formal table, if the header or footer has multiple rows.

    The separate header, body, and footer sections facilitate adding content to and formatting the header, body, or footer.

  • Informal or formal table, if the header has one row.

    You can format the first row of an informal table to look like a header.

Create a table without a header or footer.

Informal table

Convert a MATLAB table to a DOM table.

DOM representation of a MATLAB table (mlreportgen.dom.MATLABTable)

Create a table with a numbered title.

Base table

You can first create a DOM table, and then create the base table from the DOM table or you can create the base table directly from a MATLAB array.

Divide a wide table into legible slices.

Base table

If a DOM table is too wide, you can create a base table from the DOM table and then use the BaseTable properties for slicing the table. You can also slice a table created as a Table or FormalTable object by using mlreportgen.utils.TableSlicer.

See Also

| | |

Related Topics