Class Style
Represents the paragraph and character styles.
Inheritance
Inherited Members
Namespace: Syncfusion.DocIO.DLS
Assembly: Syncfusion.DocIO.NET.dll
Syntax
public abstract class Style : XDLSSerializableBase, IXDLSSerializable, IStyle
Constructors
Style(WordDocument)
Initializes a new instance of the Style class with the specified WordDocument instance.
Declaration
protected Style(WordDocument doc)
Parameters
Type | Name | Description |
---|---|---|
WordDocument | doc | The WordDocument instance. |
Fields
DEF_USER_STYLE_ID
Represents the constant style Id.
Declaration
protected const int DEF_USER_STYLE_ID = 4094
Field Value
Type |
---|
System.Int32 |
m_baseStyle
Represents the IStyle object.
Declaration
protected IStyle m_baseStyle
Field Value
Type |
---|
IStyle |
m_chFormat
Represents the WCharacterFormat object.
Declaration
protected WCharacterFormat m_chFormat
Field Value
Type |
---|
WCharacterFormat |
m_linkedStyleName
Represents the string to identify style names
Declaration
protected string m_linkedStyleName
Field Value
Type |
---|
System.String |
m_nextStyle
Represents the string to identify style names
Declaration
protected string m_nextStyle
Field Value
Type |
---|
System.String |
m_tapx
Represents the byte array.
Declaration
protected byte[] m_tapx
Field Value
Type |
---|
System.Byte[] |
m_typeCode
Represents the WordStyleType
Declaration
protected WordStyleType m_typeCode
Field Value
Type |
---|
WordStyleType |
Properties
BuiltInStyleIdentifier
Gets the style as built-in Word style.
Declaration
public BuiltinStyle BuiltInStyleIdentifier { get; }
Property Value
Type | Description |
---|---|
BuiltinStyle | The BuiltinStyle member that specifies built-in style. |
CharacterFormat
Gets the character format. Read-only.
Declaration
public WCharacterFormat CharacterFormat { get; }
Property Value
Type | Description |
---|---|
WCharacterFormat | The WCharacterFormat object that specifies the character format for the current style. |
IsPrimaryStyle
Gets or sets a value indicating whether the current instance is primary style.
Declaration
public bool IsPrimaryStyle { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
LinkedStyleName
Gets or sets the name of the style that is linked to this style. The default value is null.
Declaration
public string LinkedStyleName { get; set; }
Property Value
Type | Description |
---|---|
System.String | The string that represents the style name. |
Remarks
Character styles can be linked to paragraph and table styles and vice versa. However, you cannot link paragraph style with the table style.
Examples
Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Template.docx");
Gets the style from document styles collection
Style style = document.Styles.FindByName("ParaStyle") as Style;
Link the styles
style.LinkedStyleName = "CharStyle";
Save and Close the Word document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
'Load an existing Word document into DocIO instance
Dim document As WordDocument = New WordDocument("Template.docx")
'Gets the style from document styles collection
Dim style As Style = TryCast(document.Styles.FindByName("ParaStyle"), Style)
'Link the styles
style.LinkedStyleName = "CharStyle"
'Save and Close the Word document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
Name
Gets or sets the style name.
Declaration
public string Name { get; set; }
Property Value
Type | Description |
---|---|
System.String | The string that represents the style name. |
StyleType
Gets the type of the style. Read-only.
Declaration
public abstract StyleType StyleType { get; }
Property Value
Type | Description |
---|---|
StyleType | The StyleType member that specifies the type of the style. |
Methods
ApplyBaseStyle(BuiltinStyle)
Applies the base style for the current style.
Declaration
public void ApplyBaseStyle(BuiltinStyle bStyle)
Parameters
Type | Name | Description |
---|---|---|
BuiltinStyle | bStyle | The BuiltinStyle member that specifies the built-in style. |
ApplyBaseStyle(String)
Applies the base style for current style.
Declaration
public virtual void ApplyBaseStyle(string styleName)
Parameters
Type | Name | Description |
---|---|---|
System.String | styleName | The string that represents the style name. |
Clone()
Clones the IStyle, creating duplicate style.
Declaration
public abstract IStyle Clone()
Returns
Type |
---|
IStyle |
CloneImpl()
Clones style, creates duplicate copy of the style.
Declaration
protected override object CloneImpl()
Returns
Type | Description |
---|---|
System.Object | The cloned element |
Overrides
CreateBuiltinStyle(BuiltinStyle, StyleType, WordDocument)
Creates the built-in style.
Declaration
public static IStyle CreateBuiltinStyle(BuiltinStyle bStyle, StyleType type, WordDocument doc)
Parameters
Type | Name | Description |
---|---|---|
BuiltinStyle | bStyle | The BuiltinStyle member that specifies the built-in style. |
StyleType | type | The StyleType member that specifies the type of the style. |
WordDocument | doc | The WordDocument object. |
Returns
Type | Description |
---|---|
IStyle | The IStyle object. |
CreateBuiltinStyle(BuiltinStyle, WordDocument)
Creates the built-in paragraph style.
Declaration
public static IStyle CreateBuiltinStyle(BuiltinStyle bStyle, WordDocument doc)
Parameters
Type | Name | Description |
---|---|---|
BuiltinStyle | bStyle | The BuiltinStyle member that specifies the built-in style. |
WordDocument | doc | The WordDocument object. |
Returns
Type | Description |
---|---|
IStyle | The IStyle object. |
InitXDLSHolder()
Registers child objects in XDSL holder.
Declaration
protected override void InitXDLSHolder()
Overrides
NameToBuiltIn(String)
Converts the style names to BuiltinStyle.
Declaration
public static BuiltinStyle NameToBuiltIn(string styleName)
Parameters
Type | Name | Description |
---|---|---|
System.String | styleName | The string represents the name of the style. |
Returns
Type | Description |
---|---|
BuiltinStyle | The BuiltinStyle member that represents built-in style. |
ReadXmlAttributes(IXDLSAttributeReader)
Reads object data from xml attributes.
Declaration
protected override void ReadXmlAttributes(IXDLSAttributeReader reader)
Parameters
Type | Name | Description |
---|---|---|
IXDLSAttributeReader | reader | The IXDLSAttributeReader object. |
Overrides
Remove()
Remove this style from the Word document.
Declaration
public void Remove()
RestoreReference(String, Int32)
Restores object references after deserialization
Declaration
protected override void RestoreReference(string name, int index)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The string that represents the name. |
System.Int32 | index | The zero-based integer that represents the index. |
Overrides
WriteXmlAttributes(IXDLSAttributeWriter)
Writes object data as xml attributes.
Declaration
protected override void WriteXmlAttributes(IXDLSAttributeWriter writer)
Parameters
Type | Name | Description |
---|---|---|
IXDLSAttributeWriter | writer | The IXDLSAttributeWriter object. |
Overrides
Explicit Interface Implementations
IStyle.Close()
Declaration
void IStyle.Close()