mlreportgen.dom.TemplateStylesheet Class
Namespace: mlreportgen.dom
Description
The mlreportgen.dom.TemplateStylesheet
class contains the styles for a
mlreportgen.dom.Template
object. On opening, the
mlreportgen.dom.Template
creates an instance of
mlreportgen.dom.TemplateStylesheet
in its Stylesheet
property. Creating the mlreportgen.dom.Template
object, which is based on the
source template document, automatically populates its Stylesheet
property with the styles already present in the source template. Use the methods of this class
to add, remove, or replace styles. The parent mlreportgen.dom.Template
object
generates all styles in the TemplateStylesheet
object in the resulting
template document.
Note
DOM format classes such as mlreportgen.dom.Bold
and
mlreportgen.dom.Color
define the formatting for new styles. DOM template
style classes do not support these formatting classes:
ListStyleType
NumberFormat
OutlineLevel
ScaleToFit
DOM template style classes for DOCX template output do not support these DOM format classes:
CounterInc
CounterReset
FlowDirection
(supported forTemplateParagraphStyle
only)Height
ResizeToFitContents
RowHeight
TextOrientation
Width
WhiteSpace
The mlreportgen.dom.TemplateStylesheet
class is a handle
class.
Properties
TextStyles
— Text styles defined in style sheet
[]
(default) | array of TemplateTextStyle
objects
Text styles defined in the style sheet, specified as an array of DOM mlreportgen.dom.TemplateTextStyle
objects. To add or remove styles, use the
addStyle
, removeStyle
, or
replaceStyle
methods.
Attributes:
SetAccess | private |
NonCopyable | true |
ParagraphStyles
— Paragraph styles defined in style sheet
[]
(default) | array of TemplateParagraphStyle
objects
Paragraph styles defined in the style sheet, specified as an array of DOM mlreportgen.dom.TemplateParagraphStyle
objects. To add or remove styles, use
the addStyle
, removeStyle
, or
replaceStyle
methods.
Attributes:
SetAccess | private |
NonCopyable | true |
LinkedStyles
— Linked styles defined in style sheet
[]
(default) | array of TemplateLinkedStyle
objects
Linked styles, which are the styles that can be applied to both text and paragraph
document elements objects, defined in the style sheet, specified as an array of DOM
TemplateLinkedStyle
objects. To add or remove styles, use the
addStyle
, removeStyle
, or
replaceStyle
methods.
Attributes:
SetAccess | private |
NonCopyable | true |
TemplateStyles
— Existing styles in source template
[]
(default) | array of TemplateDOCXStyle
,
TemplateHTMLStyle
, and TemplatePDFStyle
objects
Existing styles defined in the source template, specified as an array of mlreportgen.dom.TemplateDOCXStyle
, mlreportgen.dom.TemplateHTMLStyle
, and mlreportgen.dom.TemplatePDFStyle
objects. To add or remove styles, use the
addStyle
, removeStyle
, or
replaceStyle
methods.
Attributes:
SetAccess | private |
NonCopyable | true |
Tag
— Tag for mlreportgen.dom.TemplateStylesheet
object
character vector | string scalar
Tag for the mlreportgen.dom.TemplateStylesheet
object, specified as a character vector or
string scalar. The DOM API generates a session-unique tag as part of the creation of
this object. The generated tag has the form
CLASS:ID
, where
CLASS
is the object class and
ID
is the value of the
Id
property of the object. Specify your own tag value to help
you identify where to look when an issue occurs during document generation.
Attributes:
NonCopyable | true |
Data Types: char
| string
Id
— Object identifier for mlreportgen.dom.TemplateStylesheet
object
character vector | string scalar
Object identifier for the mlreportgen.dom.TemplateStylesheet
object, specified as a
character vector or string scalar. The DOM API generates a session-unique identifier
when it creates the document element object. You can specify your own value for
Id
.
Attributes:
NonCopyable | true |
Data Types: char
| string
Methods
Public Methods
Method | Purpose |
---|---|
getStyleNames |
|
getStyle |
|
addStyle |
Note Note: You cannot create and add a new |
replaceStyle | Replace an existing style in the style sheet
Note You cannot create and add a new |
removeStyle | Remove styles in this style sheet
|
Examples
Create a Template with Stylesheet
Add stylesheet content to a new template.
Import the DOM API namespace so you do not have to include the fully qualified names.
import mlreportgen.dom.*
Create a DOCX template.
t = Template("bookReportTemplate","docx"); open(t);
Create a text style.
textStyle = TemplateTextStyle("exampleTextStyle");
Format the text style.
textStyle.Formats = [Bold(true),Color("red")];
Add the text style to the stylesheet.
stylesheet = t.Stylesheet; addStyle(stylesheet,textStyle); close(t);
Find and Replace Styles in DOCX Template
View an existing style in a DOCX template, create a new style with modifications to that style, and replace the existing style with the modified style.
Create a DOCX Template and Examine the Default Style
Import the DOM API namespace so you do not have to use fully qualified names.
import mlreportgen.dom.*
Create a template using the default DOCX template.
t = Template("myTemplate","docx");
Open the template and check if the "rgMATLABTABLE"
style exists.
open(t);
stylesheet = t.Stylesheet;
tableStyle = getStyle(stylesheet,"rgMATLABTABLE")
tableStyle = TemplateDOCXStyle with properties: Name: 'rgMATLABTABLE' Type: 'table' Formats: [] Tag: 'dom.TemplateDOCXStyle:1738' Id: '1738'
Open the source template in Microsoft® Word.
rptview(t.TemplatePath);
Open the source template in Word. In Word, inspect the "Title"
style in the source DOCX template.
Create a Modified Style and Replace the Default Style
Create a new table style named "rgMATLABTABLE"
.
newTableStyle = TemplateTableStyle("rgMATLABTABLE");
Define formats similar to the style from the source template by using the same font, line spacing, and widow and orphan handling.
oldFormats = [LineSpacing(1),FontFamily("Calibri"),WidowOrphanControl];
Leave a 15-point space after the table.
om = OuterMargin;
om.Bottom = "15pt";
oldFormats(end + 1) = om;
Define a format that gives the table a solid border.
newFormat = Border("solid","blue");
Set the formats of the new style.
newTableStyle.Formats = [oldFormats,newFormat];
Replace the old style with the new style.
replaceStyle(stylesheet,newTableStyle);
Close the template.
close(t); rptview(t);
Version History
Introduced in R2024a
See Also
mlreportgen.dom.Template
| mlreportgen.dom.TemplateDOCXStyle
| mlreportgen.dom.TemplateHTMLStyle
| mlreportgen.dom.TemplatePDFStyle
| mlreportgen.dom.TemplateTextStyle
| mlreportgen.dom.TemplateParagraphStyle
| mlreportgen.dom.TemplateLinkedStyle
| mlreportgen.dom.TemplateOrderedListStyle
| mlreportgen.dom.TemplateTableStyle
| mlreportgen.dom.TemplateUnorderedListStyle
MATLAB 명령
다음 MATLAB 명령에 해당하는 링크를 클릭했습니다.
명령을 실행하려면 MATLAB 명령 창에 입력하십시오. 웹 브라우저는 MATLAB 명령을 지원하지 않습니다.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)