Class WTableStyle
Represents a style of WTable.
Inherited Members
Namespace: Syncfusion.DocIO.DLS
Assembly: Syncfusion.DocIO.NET.dll
Syntax
public class WTableStyle : Style, IXDLSSerializable, IWTableStyle, IStyle
Properties
CellProperties
Gets cell properties.
Declaration
public TableStyleCellProperties CellProperties { get; }
Property Value
Type |
---|
TableStyleCellProperties |
ConditionalFormattingStyles
Gets conditional formatting styles collection of the table style.
Declaration
public ConditionalFormattingStyleCollection ConditionalFormattingStyles { get; }
Property Value
Type |
---|
ConditionalFormattingStyleCollection |
ParagraphFormat
Gets the paragraph format.
Declaration
public WParagraphFormat ParagraphFormat { get; }
Property Value
Type | Description |
---|---|
WParagraphFormat | The WParagraphFormat object. |
RowProperties
Gets row properties.
Declaration
public TableStyleRowProperties RowProperties { get; }
Property Value
Type |
---|
TableStyleRowProperties |
StyleType
Gets the type of the style.
Declaration
public override StyleType StyleType { get; }
Property Value
Type | Description |
---|---|
StyleType | The StyleTypemember that specifies the type of the style. |
Overrides
TableProperties
Gets table properties.
Declaration
public TableStyleTableProperties TableProperties { get; }
Property Value
Type |
---|
TableStyleTableProperties |
Methods
ApplyBaseStyle(BuiltinTableStyle)
Applies the base style for the current table style.
Declaration
public void ApplyBaseStyle(BuiltinTableStyle tableStyle)
Parameters
Type | Name | Description |
---|---|---|
BuiltinTableStyle | tableStyle | The BuiltinTableStyle member that specifies the built-in table style. |
Examples
using (WordDocument document = new WordDocument())
{
document.EnsureMinimal();
WTable table = document.LastSection.AddTable() as WTable;
table.ResetCells(3, 2);
table[0, 0].AddParagraph().AppendText("Hi");
table[0, 1].AddParagraph().AppendText("Hi");
//Adds a new custom table style
WTableStyle tableStyle = document.AddTableStyle("CustomStyle1") as WTableStyle;
//Applies conditional formatting for first row
ConditionalFormattingStyle firstRowStyle = tableStyle.ConditionalFormattingStyles.Add(ConditionalFormattingType.FirstRow);
firstRowStyle.CharacterFormat.Bold = true;
firstRowStyle.CharacterFormat.TextColor = Color.FromArgb(255, 255, 255, 255);
firstRowStyle.CellProperties.BackColor = Color.Blue;
//Applies conditional formatting for first column
ConditionalFormattingStyle firstColumnStyle = tableStyle.ConditionalFormattingStyles.Add(ConditionalFormattingType.FirstColumn);
firstColumnStyle.CharacterFormat.Bold = true;
//Applies conditional formatting for odd row
ConditionalFormattingStyle oddRowBandingStyle = tableStyle.ConditionalFormattingStyles.Add(ConditionalFormattingType.OddRowBanding);
oddRowBandingStyle.CellProperties.BackColor = Color.Red;
//Apply built in table style as base style for CustomStyle2
tableStyle.ApplyBaseStyle(BuiltinTableStyle.TableContemporary);
//Applies the custom table style to the table
table.ApplyStyle("CustomStyle1");
//Saves and closes the document instance
document.Save("TableStyle.docx", FormatType.Docx);
}
Dim document As WordDocument = New WordDocument()
document.EnsureMinimal()
Dim table As WTable = TryCast(document.LastSection.AddTable(), WTable)
table.ResetCells(3, 2)
table(0, 0).AddParagraph().AppendText("Hi")
table(0, 1).AddParagraph().AppendText("Hi")
'Adds a new custom table style
Dim tableStyle As WTableStyle = TryCast(document.AddTableStyle("CustomStyle1"), WTableStyle)
'Applies conditional formatting for first row
Dim firstRowStyle As ConditionalFormattingStyle = tableStyle.ConditionalFormattingStyles.Add(ConditionalFormattingType.FirstRow)
firstRowStyle.CharacterFormat.Bold = True
firstRowStyle.CharacterFormat.TextColor = Color.FromArgb(255, 255, 255, 255)
firstRowStyle.CellProperties.BackColor = Color.Blue
'Applies conditional formatting for first column
Dim firstColumnStyle As ConditionalFormattingStyle = tableStyle.ConditionalFormattingStyles.Add(ConditionalFormattingType.FirstColumn)
firstColumnStyle.CharacterFormat.Bold = True
'Applies conditional formatting for odd row
Dim oddRowBandingStyle As ConditionalFormattingStyle = tableStyle.ConditionalFormattingStyles.Add(ConditionalFormattingType.OddRowBanding)
oddRowBandingStyle.CellProperties.BackColor = Color.Red
'Apply built in table style as base style for CustomStyle2
tableStyle.ApplyBaseStyle(BuiltinTableStyle.TableContemporary)
'Applies the custom table style to the table
table.ApplyStyle("CustomStyle1")
'Saves and closes the document instance
document.Save("TableStyle.docx", FormatType.Docx)
document.Close()
ApplyBaseStyle(String)
Apply base style for current style.
Declaration
public override void ApplyBaseStyle(string styleName)
Parameters
Type | Name | Description |
---|---|---|
System.String | styleName | The string that specifies the style name. |
Overrides
Clone()
Creates a duplicate copy of the style.
Declaration
public override IStyle Clone()
Returns
Type | Description |
---|---|
IStyle | The reference to the newly created style. |
Overrides
CloneImpl()
Creates a duplicate copy of the entity.
Declaration
protected override object CloneImpl()
Returns
Type | Description |
---|---|
System.Object | An object that can be casted as WTableStyle. |