User`s guide

Create and Format Tables
13-59
Create a Table from a Two-Dimensional Array
You can create a table by appending a two-dimensional numeric array or a cell array
containing built-in MATLAB data (strings and numbers) and DOM objects (Text, Table,
Image, etc.) to a document. The append function converts the array to a Table object,
appends it to the document, and returns the Table object, which you can then format.
You can also create a Table object directly by including a two-dimensional array in its
constructor.
This example shows how to create a table from a numeric array and another table from
a cell array of various object types. The cell array contains a magic square, which is
rendered as an inner table. The cell array also includes a Text object constructor that
uses the AlertLevel template style.
import mlreportgen.dom.*;
doc = Document('test');
table1 = append(doc,magic(5));
table1.Border = 'single';
table1.ColSep = 'single';
table1.RowSep = 'single';
ca = {'text entry',Paragraph('a paragraph entry'); ...
Text('Danger!','AlertLevel'),magic(4)};
table2 = Table(ca);
append(doc,table2);
close(doc);
rptview(doc.OutputPath);
Create a Table Using the Table entry Function
You can use the entry function with a Table object to add content to a table entry
or to format an entry. This approach is useful when you need to format table entries
individually. For example:
import mlreportgen.dom.*;
doc = Document('test');
a = magic(5);
[v,i] = max(a);
[v1,i1] = max(max(a));