User`s guide
Create and Format Tables
13-65
font-family: Arial, Helvetica, sans-serif;
font-size: 11pt;
text-align: center;
}
Apply a Table Style to a Table
Once you have defined a table style in a template, you can apply it to a Table object in
your report program either as the second argument in the Table object constructor or
by setting it to the StyleName property of the Table object. For example, suppose you
have defined styles named BodyPara, TableTitle, and RuledTable in the template
for your report. This example specifies style names in a Paragraph constructor, in the
StyleName property of a Paragraph object, and in a Table constructor.
import mlreportgen.dom.*;
rank = 5;
rpt = Document('MyReport','html','MyTemplate');
p = Paragraph('Here is a magic square or rank 5:','BodyPara');
append(rpt,p);
p = Paragraph(sprintf('Rank %d MagicSquare',rank));
p.StyleName = 'TableTitle';
append(rpt,Table(magic(rank),'RuledTable'));
close(rpt);
rptview(rpt.OutputPath);
You can use programmatic formats to override the styles defined in a template-based
table style. For example, suppose you define a table style named UnruledTable in your
template to create tables without any borders or column or row separators. You can then
override the style in your report program to draw a frame around a table.
import mlreportgen.dom.*;
rpt = Document('MyReport','html','MyTemplate');
table = Table(magic(5),'UnruledTable');
table.Border = 'single';
append(rpt,table);
close(rpt);
rptview(rpt.OutputPath);