User`s guide
13 Create a Report Program
13-44
1
Open the Word template used with the report.
2
Open the Styles pane.
3
Click the Manage Styles button .
4
Click New Style.
5
In the Create New Style from Formatting dialog box, set Style type to Character
or Linked (paragraph and character).
For more information about working with Word styles, see “Modify Styles in a Microsoft
Word Template” on page 13-117.
Format Text Using HTML Style Sheets
You can format text using a style defined in the HTML template used to generate the
report. Apply a template style to a Text object either as the second argument in a Text
object constructor or by setting the StyleName property to a template style.
For an HTML report, use a span style. For example:
span.Pass {
font-family: "Times New Roman", Times, serif;
color: green;
}
For more information about using HTML styles with DOM objects, see “Modify Styles in
an HTML Template” on page 13-127 .
Apply a Style to a Text Object
Apply a template style to a Text object either as the second argument in a Text object
constructor or by setting the StyleName property to a template style. For example,
suppose you have defined styles named Body, Pass, and Fail in the template for your
report. You can then apply the styles as follows.
import mlreportgen.dom.*;
passed = rand(1) >= 0.5;
rpt = Document('MyReport','html','MyTemplate');
t1 = Text('Test status: ');
t1.StyleName = 'Body';
t1.WhiteSpace = 'preserve';