ConditionalStyle Class
Represents special formatting applied to some area of a table with assigned table style.
Inheritance Hierarchy
SystemObject
  Aspose.WordsConditionalStyle

Namespace: Aspose.Words
Assembly: Aspose.Words (in Aspose.Words.dll) Version: 19.11
Syntax
public sealed class ConditionalStyle

The ConditionalStyle type exposes the following members.

Properties
  NameDescription
Public propertyCode exampleBorders
Gets the collection of default cell borders for the conditional style.
Public propertyCode exampleBottomPadding
Gets or sets the amount of space (in points) to add below the contents of table cells.
Public propertyCode exampleFont
Gets the character formatting of the conditional style.
Public propertyCode exampleLeftPadding
Gets or sets the amount of space (in points) to add to the left of the contents of table cells.
Public propertyCode exampleParagraphFormat
Gets the paragraph formatting of the conditional style.
Public propertyCode exampleRightPadding
Gets or sets the amount of space (in points) to add to the right of the contents of table cells.
Public propertyCode exampleShading
Gets a Shading object that refers to the shading formatting for this conditional style.
Public propertyCode exampleTopPadding
Gets or sets the amount of space (in points) to add above the contents of table cells.
Public propertyCode exampleType
Gets table area to which this conditional style relates.
Methods
  NameDescription
Public methodCode exampleClearFormatting
Clears formatting of this conditional style.
Public methodEquals (Inherited from Object.)
Public methodGetHashCode (Inherited from Object.)
Public methodGetType (Inherited from Object.)
Public methodToString (Inherited from Object.)
Examples
Shows how to work with certain area styles of a table.
Document doc = new Document(MyDir + "Table.ConditionalStyles.docx");

TableStyle tableStyle = (TableStyle)doc.Styles.Add(StyleType.Table, "MyTableStyle1");
// There is a different ways how to get conditional styles:
// by conditional style type
tableStyle.ConditionalStyles[ConditionalStyleType.FirstRow].Shading.BackgroundPatternColor = Color.AliceBlue;
// by index
tableStyle.ConditionalStyles[0].Borders.Color = Color.Black;
tableStyle.ConditionalStyles[0].Borders.LineStyle = LineStyle.DotDash;
Assert.AreEqual(ConditionalStyleType.FirstRow, tableStyle.ConditionalStyles[0].Type);
// directly from ConditionalStyleCollection
tableStyle.ConditionalStyles.FirstRow.ParagraphFormat.Alignment = ParagraphAlignment.Center;
// To see this in Word document select Total Row checkbox in Design Tab
tableStyle.ConditionalStyles.LastRow.BottomPadding = 10;
tableStyle.ConditionalStyles.LastRow.LeftPadding = 10;
tableStyle.ConditionalStyles.LastRow.RightPadding = 10;
tableStyle.ConditionalStyles.LastRow.TopPadding = 10;
// To see this in Word document select Last Column checkbox in Design Tab
tableStyle.ConditionalStyles.LastColumn.Font.Bold = true;

Console.WriteLine(tableStyle.ConditionalStyles.Count);
Console.WriteLine(tableStyle.ConditionalStyles[0].Type);

Table table = (Table) doc.GetChild(NodeType.Table, 0, true);
table.Style = tableStyle;

doc.Save(ArtifactsDir + "Table.WorkWithTableConditionalStyles.docx");
See Also