TableStyle Class
Represents a table style.
Inheritance Hierarchy
SystemObject
  Aspose.WordsStyle
    Aspose.WordsTableStyle

Namespace: Aspose.Words
Assembly: Aspose.Words (in Aspose.Words.dll) Version: 19.11
Syntax
public class TableStyle : Style

The TableStyle type exposes the following members.

Properties
  NameDescription
Public propertyAliases
Gets all aliases of this style. If style has no aliases then empty array of string is returned.
(Inherited from Style.)
Public propertyCode exampleAlignment
Specifies the alignment for the table style.
Public propertyCode exampleAllowBreakAcrossPages
Gets or sets a flag indicating whether text in a table row is allowed to split across a page break.
Public propertyBaseStyleName
Gets/sets the name of the style this style is based on.
(Inherited from Style.)
Public propertyCode exampleBidi
Gets or sets whether this is a style for a right-to-left table.
Public propertyCode exampleBorders
Gets the collection of default cell borders for the style.
Public propertyCode exampleBottomPadding
Gets or sets the amount of space (in points) to add below the contents of table cells.
Public propertyCode exampleBuiltIn
True if this style is one of the built-in styles in MS Word.
(Inherited from Style.)
Public propertyCode exampleCellSpacing
Gets or sets the amount of space (in points) between the cells.
Public propertyCode exampleColumnStripe
Gets or sets a number of columns to include in the banding when the style specifies odd/even columns banding.
Public propertyCode exampleConditionalStyles
Collection of conditional styles that may be defined for this table style.
Public propertyDocument
Gets the owner document.
(Inherited from Style.)
Public propertyCode exampleFont
Gets the character formatting of the style.
(Inherited from Style.)
Public propertyIsHeading
True when the style is one of the built-in Heading styles.
(Inherited from Style.)
Public propertyIsQuickStyle
Specifies whether this style is shown in the Quick Style gallery inside MS Word UI.
(Inherited from Style.)
Public propertyCode exampleLeftIndent
Gets or sets the value that represents the left indent of a table.
Public propertyCode exampleLeftPadding
Gets or sets the amount of space (in points) to add to the left of the contents of table cells.
Public propertyLinkedStyleName
Gets the name of the Style linked to this one. Returns Empty string if no styles are linked.
(Inherited from Style.)
Public propertyCode exampleList
Gets the list that defines formatting of this list style.
(Inherited from Style.)
Public propertyCode exampleListFormat
Provides access to the list formatting properties of a paragraph style.
(Inherited from Style.)
Public propertyCode exampleName
Gets or sets the name of the style.
(Inherited from Style.)
Public propertyNextParagraphStyleName
Gets/sets the name of the style to be applied automatically to a new paragraph inserted after a paragraph formatted with the specified style.
(Inherited from Style.)
Public propertyCode exampleParagraphFormat
Gets the paragraph formatting of the style.
(Inherited from 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 exampleRowStripe
Gets or sets a number of rows to include in the banding when the style specifies odd/even row banding.
Public propertyCode exampleShading
Gets a Shading object that refers to the shading formatting for table cells.
Public propertyCode exampleStyleIdentifier
Gets the locale independent style identifier for a built-in style.
(Inherited from Style.)
Public propertyStyles
Gets the collection of styles this style belongs to.
(Inherited from Style.)
Public propertyCode exampleTopPadding
Gets or sets the amount of space (in points) to add above the contents of table cells.
Public propertyType
Gets the style type (paragraph or character).
(Inherited from Style.)
Methods
  NameDescription
Public methodEquals(Object) (Inherited from Object.)
Public methodEquals(Style)
Compares with the specified style. Styles Istds are compared for built-in styles only. Styles defaults are not included in comparison. Base style, linked style and next paragraph style are recursively compared.
(Inherited from Style.)
Protected methodFinalize (Inherited from Object.)
Public methodGetHashCode (Inherited from Object.)
Public methodGetType (Inherited from Object.)
Protected methodMemberwiseClone (Inherited from Object.)
Public methodCode exampleRemove
Removes the specified style from the document.
(Inherited from Style.)
Public methodToString (Inherited from Object.)
Examples
Shows how to create your own style settings for the table.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

Table table = builder.StartTable();
builder.InsertCell();
builder.Write("Name");
builder.InsertCell();
builder.Write("مرحبًا");
builder.EndRow();
builder.InsertCell();
builder.InsertCell();
builder.EndTable();

TableStyle tableStyle = (TableStyle)doc.Styles.Add(StyleType.Table, "MyTableStyle1");
tableStyle.AllowBreakAcrossPages = true;
tableStyle.Bidi = true;
tableStyle.CellSpacing = 5.0;
tableStyle.BottomPadding = 20.0;
tableStyle.LeftPadding = 5;
tableStyle.RightPadding = 10;
tableStyle.TopPadding = 20.0;
tableStyle.Shading.BackgroundPatternColor = Color.AntiqueWhite;
tableStyle.Borders.Color = Color.Black;
tableStyle.Borders.LineStyle = LineStyle.DotDash;

table.Style = tableStyle;

// Some Table attributes are linked to style variables
Assert.AreEqual(true, table.Bidi);
Assert.AreEqual(5.0, table.CellSpacing);
Assert.AreEqual("MyTableStyle1", table.StyleName);

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