主要内容

创建正式表

A DOM API formal table has header, body, and footer sections. A formal table is useful when a header or footer has multiple rows. The separate header, body, and footer sections facilitate adding rows to and formatting the header, body, or footer independently of the other sections. For information about other types of tables that you can create in reports, seeChoose Type of Table to Create. For information about formatting tables, seeFormat Tables.

A formal table is represented by anmlreportgen.dom.FormalTable对象。The header, body, and footer sections are represented bymlreportgen.dom.TableHeader,mlreportgen.dom.TableBody, 和mlreportgen.dom.TableFooterobjects, respectively. Each section has rows and table entries. The rows are represented bymlreportgen.dom.TableRow对象。Entries in the body and footer sections are represented bymlreportgen.dom.TableEntry对象。Entries in the header are represented bymlreportgen.dom.TableHeaderEntry要么mlreportgen.dom.TableEntry对象。

You can create the sections of a formal table from a MATLAB®array. This approach is the simplest because you do not have to createTableRowTableEntry要么TableHeaderEntry对象。您还可以通过构建表来创建这些部分TableRowTableEntry要么TableHeaderEntry对象。This approach is useful for complex formatting requirements, such as an when an entry spans multiple columns or rows. You can combine the approaches. For example, you can create the table body from an array and build the header from rows and entries.

Create a Formal Table fromMATLABArrays

Create a formal table by using themlreportgen.dom.FormalTableconstructor. The constructor optionally accepts a two-dimensional array or a cell array of MATLAB data for the body, header, and footer sections. See the标题,body, 和页脚arguments on themlreportgen.dom.FormalTable参考页面。有关从字符串数组中创建正式表标题的示例,以及从单元格数组中的正式表身体,请参阅Create a Table from a Cell Array.

从行和条目创建正式表

You can build the header, body, or footer sections of a formal table by appending table entries to table rows and appending the rows to the sections.

To create a header entry, you can use anmlreportgen.dom.TableHeaderEntry要么mlreportgen.dom.TableEntry对象。如果you create a header from an array, the DOM API creates the entries asTableHeaderEntry对象。In an HTML report, the DOM API renders aTableHeaderEntryobject as ath(table header cell) element. This rendering relies on the browser to format the table entry. For Word and PDF reports, by default, the DOM API renders theTableHeaderEntryobject as an unformatted Word or PDF table entry element. You can use theTableHeaderEntryobject properties to format the table entries generated for all output types. For example, you can use these properties to override browser formatting in HTML reports.

要从表行和条目构建正式表的一部分,可以使用FormalTableappendHeaderRow,append, 和appendFooterRowmethods to append rows to the table header, body, or footer sections. Alternatively, you can access a section by using theHeader,身体, orFooterproperties of theFormalTableobject and then append rows to the section by using theappend方法。

For an example that builds a header from entries and rows, seeFormal TableinSpan a Table Entry Across Rows and Columns.

See Also

|||||||

相关话题