Aspose::Words::TableStyle class

TableStyle class

Represents a table style. To learn more, visit the Working with Tables documentation article.

class TableStyle : public Style,
                   public ICellAttrSource,
                   public IRowAttrSource,
                   public IBorderAttrSource,
                   public IShadingAttrSource

Methods

MethodDescription
get_Alignment()Specifies the alignment for the table style.
get_AllowBreakAcrossPages()Gets or sets a flag indicating whether text in a table row is allowed to split across a page break.
get_Borders()Gets the collection of default cell borders for the style.
get_BottomPadding()Gets or sets the amount of space (in points) to add below the contents of table cells.
get_CellSpacing()Gets or sets the amount of space (in points) between the cells.
get_ColumnStripe()Gets or sets a number of columns to include in the banding when the style specifies odd/even columns banding.
get_ConditionalStyles()Collection of conditional styles that may be defined for this table style.
get_LeftIndent()Gets or sets the value that represents the left indent of a table.
get_LeftPadding()Gets or sets the amount of space (in points) to add to the left of the contents of table cells.
get_RightPadding()Gets or sets the amount of space (in points) to add to the right of the contents of table cells.
get_RowStripe()Gets or sets a number of rows to include in the banding when the style specifies odd/even row banding.
get_Shading()Gets a Shading object that refers to the shading formatting for table cells.
get_TopPadding()Gets or sets the amount of space (in points) to add above the contents of table cells.
get_VerticalAlignment()Specifies the vertical alignment for the cells.
set_Alignment(Aspose::Words::Tables::TableAlignment)Specifies the alignment for the table style.
set_AllowBreakAcrossPages(bool)Sets a flag indicating whether text in a table row is allowed to split across a page break.
set_BottomPadding(double)Sets the amount of space (in points) to add below the contents of table cells.
set_CellSpacing(double)Sets the amount of space (in points) between the cells.
set_ColumnStripe(int32_t)Sets a number of columns to include in the banding when the style specifies odd/even columns banding.
set_LeftIndent(double)Sets the value that represents the left indent of a table.
set_LeftPadding(double)Sets the amount of space (in points) to add to the left of the contents of table cells.
set_RightPadding(double)Sets the amount of space (in points) to add to the right of the contents of table cells.
set_RowStripe(int32_t)Sets a number of rows to include in the banding when the style specifies odd/even row banding.
set_TopPadding(double)Sets the amount of space (in points) to add above the contents of table cells.
set_VerticalAlignment(Aspose::Words::Tables::CellVerticalAlignment)Specifies the vertical alignment for the cells.
Equals(const System::SharedPtr<Aspose::Words::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.
get_Aliases()Gets all aliases of this style. If style has no aliases then empty array of string is returned.
get_AutomaticallyUpdate() constSpecifies whether this style is automatically redefined based on the appropriate value.
get_BaseStyleName()Gets/sets the name of the style this style is based on.
get_BuiltIn()True if this style is one of the built-in styles in MS Word.
get_Document()Gets the owner document.
get_Font()Gets the character formatting of the style.
get_IsHeading()True when the style is one of the built-in Heading styles.
get_IsQuickStyle() constSpecifies whether this style is shown in the Quick Style gallery inside MS Word UI.
get_LinkedStyleName()Gets/sets the name of the Style linked to this one. Returns empty string if no styles are linked.
get_List()Gets the list that defines formatting of this list style.
get_ListFormat()Provides access to the list formatting properties of a paragraph style.
get_Locked() constSpecifies whether this style is locked.
get_Name() constGets or sets the name of the style.
get_NextParagraphStyleName()Gets/sets the name of the style to be applied automatically to a new paragraph inserted after a paragraph formatted with the specified style.
get_ParagraphFormat()Gets the paragraph formatting of the style.
get_Priority() constGets/sets the integer value that represents the priority for sorting the styles in the Styles task pane.
get_SemiHidden() constGets/sets whether the style hides from the Styles gallery and from the Styles task pane.
get_StyleIdentifier() constGets the locale independent style identifier for a built-in style.
get_Styles() constGets the collection of styles this style belongs to.
get_Type() constGets the style type (paragraph or character).
get_UnhideWhenUsed() constGets/sets whether the style used in the current document unhides from the Styles gallery and from the Styles task pane. True when the used style should be shown in the Styles gallery.
set_AutomaticallyUpdate(bool)Specifies whether this style is automatically redefined based on the appropriate value.
set_BaseStyleName(const System::String &)Gets/sets the name of the style this style is based on.
set_IsQuickStyle(bool)Specifies whether this style is shown in the Quick Style gallery inside MS Word UI.
set_LinkedStyleName(const System::String &)Gets/sets the name of the Style linked to this one. Returns empty string if no styles are linked.
set_Locked(bool)Specifies whether this style is locked.
set_Name(const System::String &)Sets the name of the style.
set_NextParagraphStyleName(const System::String &)Gets/sets the name of the style to be applied automatically to a new paragraph inserted after a paragraph formatted with the specified style.
set_Priority(int32_t)Gets/sets the integer value that represents the priority for sorting the styles in the Styles task pane.
set_SemiHidden(bool)Gets/sets whether the style hides from the Styles gallery and from the Styles task pane.
set_UnhideWhenUsed(bool)Gets/sets whether the style used in the current document unhides from the Styles gallery and from the Styles task pane. True when the used style should be shown in the Styles gallery.

Examples

Shows how to create custom style settings for the table.

auto doc = System::MakeObject<Aspose::Words::Document>();
auto builder = System::MakeObject<Aspose::Words::DocumentBuilder>(doc);

System::SharedPtr<Aspose::Words::Tables::Table> table = builder->StartTable();
builder->InsertCell();
builder->Write(u"Name");
builder->InsertCell();
builder->Write(u"مرحبًا");
builder->EndRow();
builder->InsertCell();
builder->InsertCell();
builder->EndTable();

auto tableStyle = System::ExplicitCast<Aspose::Words::TableStyle>(doc->get_Styles()->Add(StyleType::Table, u"MyTableStyle1"));
tableStyle->set_AllowBreakAcrossPages(true);
tableStyle->set_CellSpacing(5);
tableStyle->set_BottomPadding(20);
tableStyle->set_LeftPadding(5);
tableStyle->set_RightPadding(10);
tableStyle->set_TopPadding(20);
tableStyle->get_Shading()->set_BackgroundPatternColor(System::Drawing::Color::get_AntiqueWhite());
tableStyle->get_Borders()->set_Color(System::Drawing::Color::get_Blue());
tableStyle->get_Borders()->set_LineStyle(LineStyle::DotDash);
tableStyle->set_VerticalAlignment(CellVerticalAlignment::Center);

table->set_Style(tableStyle);

// Setting the style properties of a table may affect the properties of the table itself.
ASSERT_FALSE(table->get_Bidi());
ASPOSE_ASSERT_EQ(table->get_CellSpacing(), 5.0);
ASSERT_EQ(table->get_StyleName(), u"MyTableStyle1");

doc->Save(get_ArtifactsDir() + u"Table.TableStyleCreation.docx");

See Also