Aspose::Words::TableStyle class

TableStyle class

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

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

Methods

MethodDescription
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.
get_Aliases()Gets all aliases of this style. If style has no aliases then empty array of string is returned.
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_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_Bidi()Gets or sets whether this is a style for a right-to-left table.
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_BuiltIn()True if this style is one of the built-in styles in MS Word.
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_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_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_LinkedStyleName()Gets 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() const
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() const
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_SemiHidden() const
get_Shading()Gets a Shading object that refers to the shading formatting for table cells.
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_TopPadding()Gets or sets the amount of space (in points) to add above the contents of table cells.
get_Type() constGets the style type (paragraph or character).
get_UnhideWhenUsed() const
get_VerticalAlignment()Specifies the vertical alignment for the cells.
GetType() const override
Is(const System::TypeInfo&) const override
Remove()Removes the specified style from the document.
set_Alignment(Aspose::Words::Tables::TableAlignment)Setter for Aspose::Words::TableStyle::get_Alignment.
set_AllowBreakAcrossPages(bool)Setter for Aspose::Words::TableStyle::get_AllowBreakAcrossPages.
set_AutomaticallyUpdate(bool)Setter for Aspose::Words::Style::get_AutomaticallyUpdate.
set_BaseStyleName(const System::String&)Setter for Aspose::Words::Style::get_BaseStyleName.
set_Bidi(bool)Setter for Aspose::Words::TableStyle::get_Bidi.
set_BottomPadding(double)Setter for Aspose::Words::TableStyle::get_BottomPadding.
set_CellSpacing(double)Setter for Aspose::Words::TableStyle::get_CellSpacing.
set_ColumnStripe(int32_t)Setter for Aspose::Words::TableStyle::get_ColumnStripe.
set_IsQuickStyle(bool)Setter for Aspose::Words::Style::get_IsQuickStyle.
set_LeftIndent(double)Setter for Aspose::Words::TableStyle::get_LeftIndent.
set_LeftPadding(double)Setter for Aspose::Words::TableStyle::get_LeftPadding.
set_LinkedStyleName(const System::String&)Setter for Aspose::Words::Style::get_LinkedStyleName.
set_Locked(bool)
set_Name(const System::String&)Setter for Aspose::Words::Style::get_Name.
set_NextParagraphStyleName(const System::String&)Setter for Aspose::Words::Style::get_NextParagraphStyleName.
set_Priority(int32_t)
set_RightPadding(double)Setter for Aspose::Words::TableStyle::get_RightPadding.
set_RowStripe(int32_t)Setter for Aspose::Words::TableStyle::get_RowStripe.
set_SemiHidden(bool)
set_TopPadding(double)Setter for Aspose::Words::TableStyle::get_TopPadding.
set_UnhideWhenUsed(bool)
set_VerticalAlignment(Aspose::Words::Tables::CellVerticalAlignment)Setter for Aspose::Words::TableStyle::get_VerticalAlignment.
static Type()

Examples

Shows how to create custom style settings for the table.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);

SharedPtr<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<TableStyle>(doc->get_Styles()->Add(StyleType::Table, u"MyTableStyle1"));
tableStyle->set_AllowBreakAcrossPages(true);
tableStyle->set_Bidi(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_TRUE(table->get_Bidi());
ASPOSE_ASSERT_EQ(5.0, table->get_CellSpacing());
ASSERT_EQ(u"MyTableStyle1", table->get_StyleName());

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

See Also