User`s guide
13 Create a Report Program
13-60
table = Table(a);
text = table.entry(i(i1),i1).Children(1);
text.Color = 'red';
append(doc,table);
close(doc);
rptview(doc.OutputPath);
Create a Table from Scratch
You can create a table from scratch by creating TableEntry objects, appending them to
TableRow objects, and appending the TableRow objects to a Table object. This approach
is useful when you need to create table entries that span multiple columns or rows that
have a different number of entries. This example shows how to create a table with four
columns and two rows. In the first table row, the second entry spans the second and third
columns.
import mlreportgen.dom.*;
doc = Document('test');
table = Table(4);
table.Border = 'single';
table.ColSep = 'single';
table.RowSep = 'single';
row = TableRow;
append(row, TableEntry('entry 11'));
te = TableEntry('entry 12-13');
te.ColSpan = 2;
te.Border = 'single';
append(row, te);
append(row, TableEntry('entry 14'));
append(table,row);
row = TableRow;
for c = 1:4
append(row, TableEntry(sprintf('entry 2%i', c)));
end
append(table,row);
append(doc,table);