TableStyle
Contents
[
Hide
]TableStyle class
Represents a table style.
To learn more, visit the Working with Tables documentation article.
public class TableStyle : Style
Properties
Name | Description |
---|---|
Aliases { get; } | Gets all aliases of this style. If style has no aliases then empty array of string is returned. |
Alignment { get; set; } | Specifies the alignment for the table style. |
AllowBreakAcrossPages { get; set; } | Gets or sets a flag indicating whether text in a table row is allowed to split across a page break. |
AutomaticallyUpdate { get; set; } | Specifies whether this style is automatically redefined based on the appropriate value. |
BaseStyleName { get; set; } | Gets/sets the name of the style this style is based on. |
Bidi { get; set; } | Gets or sets whether this is a style for a right-to-left table. |
Borders { get; } | Gets the collection of default cell borders for the style. |
BottomPadding { get; set; } | Gets or sets the amount of space (in points) to add below the contents of table cells. |
BuiltIn { get; } | True if this style is one of the built-in styles in MS Word. |
CellSpacing { get; set; } | Gets or sets the amount of space (in points) between the cells. |
ColumnStripe { get; set; } | Gets or sets a number of columns to include in the banding when the style specifies odd/even columns banding. |
ConditionalStyles { get; } | Collection of conditional styles that may be defined for this table style. |
Document { get; } | Gets the owner document. |
Font { get; } | Gets the character formatting of the style. |
IsHeading { get; } | True when the style is one of the built-in Heading styles. |
IsQuickStyle { get; set; } | Specifies whether this style is shown in the Quick Style gallery inside MS Word UI. |
LeftIndent { get; set; } | Gets or sets the value that represents the left indent of a table. |
LeftPadding { get; set; } | Gets or sets the amount of space (in points) to add to the left of the contents of table cells. |
LinkedStyleName { get; } | Gets the name of the Style linked to this one. Returns empty string if no styles are linked. |
List { get; } | Gets the list that defines formatting of this list style. |
ListFormat { get; } | Provides access to the list formatting properties of a paragraph style. |
Name { get; set; } | Gets or sets the name of the style. |
NextParagraphStyleName { get; set; } | Gets/sets the name of the style to be applied automatically to a new paragraph inserted after a paragraph formatted with the specified style. |
ParagraphFormat { get; } | Gets the paragraph formatting of the style. |
RightPadding { get; set; } | Gets or sets the amount of space (in points) to add to the right of the contents of table cells. |
RowStripe { get; set; } | Gets or sets a number of rows to include in the banding when the style specifies odd/even row banding. |
Shading { get; } | Gets a Shading object that refers to the shading formatting for table cells. |
StyleIdentifier { get; } | Gets the locale independent style identifier for a built-in style. |
Styles { get; } | Gets the collection of styles this style belongs to. |
TopPadding { get; set; } | Gets or sets the amount of space (in points) to add above the contents of table cells. |
Type { get; } | Gets the style type (paragraph or character). |
VerticalAlignment { get; set; } | Specifies the vertical alignment for the cells. |
Methods
Name | Description |
---|---|
Equals(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. |
Remove() | Removes the specified style from the document. |
Examples
Shows how to create custom 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;
tableStyle.BottomPadding = 20;
tableStyle.LeftPadding = 5;
tableStyle.RightPadding = 10;
tableStyle.TopPadding = 20;
tableStyle.Shading.BackgroundPatternColor = Color.AntiqueWhite;
tableStyle.Borders.Color = Color.Blue;
tableStyle.Borders.LineStyle = LineStyle.DotDash;
tableStyle.VerticalAlignment = CellVerticalAlignment.Center;
table.Style = tableStyle;
// Setting the style properties of a table may affect the properties of the table itself.
Assert.True(table.Bidi);
Assert.AreEqual(5.0d, table.CellSpacing);
Assert.AreEqual("MyTableStyle1", table.StyleName);
doc.Save(ArtifactsDir + "Table.TableStyleCreation.docx");
See Also
- class Style
- namespace Aspose.Words
- assembly Aspose.Words