Main Content

Choose Type of Table to Create in Report Generator

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 TableClassExampleMore 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

Choose the type of table to create based on your table requirements. In some cases, more than one type of table meets your requirements, choose the type of table based on your preferences.

RequirementType of Table

Create a table with a header or footer.

  • If the header or footer has multiple rows, use a formal table. The separate header, body, and footer sections make it easier to add content to and format the header, body, or footer.

  • If the header has one row, use an informal or formal table. 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.

MATLAB table

Create a table with a numbered title.

Base table

You can create a DOM table, 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 to slice the table. You can also slice a table created as a Table or FormalTable object by using mlreportgen.utils.TableSlicer.

Create an HTML table with collapsible rows. (since R2025a)

  • Informal table. For more information, see Create HTML Table with Collapsible Rows.

  • Formal table or MATLAB table. You can only collapse rows within the TableHeader, TableBody, TableFooter sections.

See Also

Classes

Topics