Use Style Sheet Styles
A style is a collection of formats that define the appearance of a document object, such as a paragraph, table, or list. You can define and name styles in templates and then assign the names to paragraphs, tables, and other document elements in your report program. The style determines how the document object renders in the output.
In a Word template, you can define styles and save styles that belong together in a style sheet (also called a style set). In an HTML template, you define styles in a cascading style sheet (CSS) file. You define styles for PDF documents in a CSS file, using a subset of CSS. See Modify Styles in PDF Templates.
You can apply style sheet styles to document objects using the
StyleName
property in your report program using this
workflow.
In the template you are using with the report, define or modify styles.
In a DOM report, create a
Document
object that uses the template that contains your styles.For the objects that you want to format with your styles, set the
StyleName
property to match the name of the style in the template.
For example, this code assigns a style named Warning
to a paragraph
object. It assumes that you have defined the Warning
style in a Word
template named MyTemplate.dotx
. Assigning the
Warning
style to the DOM paragraph object applies the
Warning
style in the template to the paragraph when you generate
the report.
d = Document('MyDoc','docx','MyTemplate'); p = Paragraph('Use care when unplugging this device.'); p.StyleName = 'Warning'; append(d,p); close(d);
Tip
Some document object constructors allow you to specify the value of the
StyleName
property as an argument. For example, this
paragraph applies the style Warning
to the paragraph containing
the specified text.
p = Paragraph('Use care when unplugging this device','Warning');
Related Examples
- Create Microsoft Word Templates
- Modify Styles in Microsoft Word Templates
- Create HTML and PDF Templates
- Modify Styles in HTML Templates
- Modify Styles in PDF Templates