search/mag_sel search/close
Aspose::Words::TableStyle Class Reference

Represents a table style.

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::DynamicCast<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");

#include <Aspose.Words.Cpp/TableStyle.h>

+ Inheritance diagram for Aspose::Words::TableStyle:

Public Member Functions

TableAlignment get_Alignment ()
 Specifies the alignment for the table style. More...
 
bool get_AllowBreakAcrossPages ()
 Gets or sets a flag indicating whether text in a table row is allowed to split across a page break. More...
 
bool get_Bidi ()
 Gets or sets whether this is a style for a right-to-left table. More...
 
SharedPtr< BorderCollectionget_Borders ()
 Gets the collection of default cell borders for the style. More...
 
double get_BottomPadding ()
 Gets or sets the amount of space (in points) to add below the contents of table cells. More...
 
double get_CellSpacing ()
 Gets or sets the amount of space (in points) between the cells. More...
 
int32_t get_ColumnStripe ()
 Gets or sets a number of columns to include in the banding when the style specifies odd/even columns banding. More...
 
SharedPtr< ConditionalStyleCollectionget_ConditionalStyles ()
 Collection of conditional styles that may be defined for this table style. More...
 
double get_LeftIndent ()
 Gets or sets the value that represents the left indent of a table. More...
 
double get_LeftPadding ()
 Gets or sets the amount of space (in points) to add to the left of the contents of table cells. More...
 
double get_RightPadding ()
 Gets or sets the amount of space (in points) to add to the right of the contents of table cells. More...
 
int32_t get_RowStripe ()
 Gets or sets a number of rows to include in the banding when the style specifies odd/even row banding. More...
 
SharedPtr< Shadingget_Shading ()
 Gets a Shading object that refers to the shading formatting for table cells. More...
 
double get_TopPadding ()
 Gets or sets the amount of space (in points) to add above the contents of table cells. More...
 
CellVerticalAlignment get_VerticalAlignment ()
 Specifies the vertical alignment for the cells. More...
 
virtual const TypeInfoGetType () const override
 
virtual bool Is (const TypeInfo &target) const override
 
void set_Alignment (TableAlignment value)
 Setter for get_Alignment. More...
 
void set_AllowBreakAcrossPages (bool value)
 Setter for get_AllowBreakAcrossPages. More...
 
void set_Bidi (bool value)
 Setter for get_Bidi. More...
 
void set_BottomPadding (double value)
 Setter for get_BottomPadding. More...
 
void set_CellSpacing (double value)
 Setter for get_CellSpacing. More...
 
void set_ColumnStripe (int32_t value)
 Setter for get_ColumnStripe. More...
 
void set_LeftIndent (double value)
 Setter for get_LeftIndent. More...
 
void set_LeftPadding (double value)
 Setter for get_LeftPadding. More...
 
void set_RightPadding (double value)
 Setter for get_RightPadding. More...
 
void set_RowStripe (int32_t value)
 Setter for get_RowStripe. More...
 
void set_TopPadding (double value)
 Setter for get_TopPadding. More...
 
void set_VerticalAlignment (CellVerticalAlignment value)
 Setter for get_VerticalAlignment. More...
 
- Public Member Functions inherited from Style
bool Equals (SharedPtr< Style > 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. More...
 
ArrayPtr< Stringget_Aliases ()
 Gets all aliases of this style. If style has no aliases then empty array of string is returned. More...
 
String get_BaseStyleName ()
 Gets/sets the name of the style this style is based on. More...
 
bool get_BuiltIn ()
 True if this style is one of the built-in styles in MS Word. More...
 
SharedPtr< DocumentBaseget_Document ()
 Gets the owner document. More...
 
SharedPtr< Fontget_Font ()
 Gets the character formatting of the style. More...
 
bool get_IsHeading ()
 True when the style is one of the built-in Heading styles. More...
 
bool get_IsQuickStyle () const
 Specifies whether this style is shown in the Quick Style gallery inside MS Word UI. More...
 
String get_LinkedStyleName ()
 Gets the name of the Style linked to this one. Returns Empty string if no styles are linked. More...
 
SharedPtr< Listget_List ()
 Gets the list that defines formatting of this list style. More...
 
SharedPtr< ListFormatget_ListFormat ()
 Provides access to the list formatting properties of a paragraph style. More...
 
String get_Name () const
 Gets or sets the name of the style. More...
 
String 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. More...
 
SharedPtr< ParagraphFormatget_ParagraphFormat ()
 Gets the paragraph formatting of the style. More...
 
StyleIdentifier get_StyleIdentifier () const
 Gets the locale independent style identifier for a built-in style. More...
 
SharedPtr< StyleCollectionget_Styles () const
 Gets the collection of styles this style belongs to. More...
 
StyleType get_Type () const
 Gets the style type (paragraph or character). More...
 
void Remove ()
 Removes the specified style from the document. More...
 
void set_BaseStyleName (String value)
 Setter for get_BaseStyleName. More...
 
void set_IsQuickStyle (bool value)
 Setter for get_IsQuickStyle. More...
 
void set_Name (String value)
 Setter for get_Name. More...
 
void set_NextParagraphStyleName (String value)
 Setter for get_NextParagraphStyleName. More...
 

Static Public Member Functions

static const TypeInfoType ()
 
- Static Public Member Functions inherited from Style
static const TypeInfoType ()
 

Member Function Documentation

◆ get_Alignment()

Aspose::Words::Tables::TableAlignment Aspose::Words::TableStyle::get_Alignment ( )

Specifies the alignment for the table style.

Examples

Shows how to set the position of a table.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Below are two ways of aligning a table horizontally.
// 1 - Use the "Alignment" property to align it to a location on the page, such as the center:
auto tableStyle = System::DynamicCast<TableStyle>(doc->get_Styles()->Add(StyleType::Table, u"MyTableStyle1"));
tableStyle->set_Alignment(TableAlignment::Center);
tableStyle->get_Borders()->set_Color(System::Drawing::Color::get_Blue());
tableStyle->get_Borders()->set_LineStyle(LineStyle::Single);
// Insert a table and apply the style we created to it.
SharedPtr<Table> table = builder->StartTable();
builder->InsertCell();
builder->Write(u"Aligned to the center of the page");
builder->EndTable();
table->set_PreferredWidth(PreferredWidth::FromPoints(300));
table->set_Style(tableStyle);
// 2 - Use the "LeftIndent" to specify an indent from the left margin of the page:
tableStyle = System::DynamicCast<TableStyle>(doc->get_Styles()->Add(StyleType::Table, u"MyTableStyle2"));
tableStyle->set_LeftIndent(55);
tableStyle->get_Borders()->set_Color(System::Drawing::Color::get_Green());
tableStyle->get_Borders()->set_LineStyle(LineStyle::Single);
table = builder->StartTable();
builder->InsertCell();
builder->Write(u"Aligned according to left indent");
builder->EndTable();
table->set_PreferredWidth(PreferredWidth::FromPoints(300));
table->set_Style(tableStyle);
doc->Save(ArtifactsDir + u"Table.SetTableAlignment.docx");

◆ get_AllowBreakAcrossPages()

bool Aspose::Words::TableStyle::get_AllowBreakAcrossPages ( )

Gets or sets a flag indicating whether text in a table row is allowed to split across a page break.

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::DynamicCast<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");

◆ get_Bidi()

bool Aspose::Words::TableStyle::get_Bidi ( )

Gets or sets whether this is a style for a right-to-left table.

When true, the cells in rows are laid out right to left.

The default value is false.

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::DynamicCast<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");

◆ get_Borders()

System::SharedPtr<Aspose::Words::BorderCollection> Aspose::Words::TableStyle::get_Borders ( )

Gets the collection of default cell borders for the style.

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::DynamicCast<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");

◆ get_BottomPadding()

double Aspose::Words::TableStyle::get_BottomPadding ( )

Gets or sets the amount of space (in points) to add below the contents of table cells.

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::DynamicCast<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");

◆ get_CellSpacing()

double Aspose::Words::TableStyle::get_CellSpacing ( )

Gets or sets the amount of space (in points) between the cells.

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::DynamicCast<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");

◆ get_ColumnStripe()

int32_t Aspose::Words::TableStyle::get_ColumnStripe ( )

Gets or sets a number of columns to include in the banding when the style specifies odd/even columns banding.

Examples

Shows how to create conditional table styles that alternate between rows.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// We can configure a conditional style of a table to apply a different color to the row/column,
// based on whether the row/column is even or odd, creating an alternating color pattern.
// We can also apply a number n to the row/column banding,
// meaning that the color alternates after every n rows/columns instead of one.
// Create a table where single columns and rows will band the columns will banded in threes.
SharedPtr<Table> table = builder->StartTable();
for (int i = 0; i < 15; i++)
{
for (int j = 0; j < 4; j++)
{
builder->InsertCell();
builder->Writeln(String::Format(u"{0} column.", (j % 2 == 0 ? String(u"Even") : String(u"Odd"))));
builder->Write(String::Format(u"Row banding {0}.", (i % 3 == 0 ? String(u"start") : String(u"continuation"))));
}
builder->EndRow();
}
builder->EndTable();
// Apply a line style to all the borders of the table.
auto tableStyle = System::DynamicCast<TableStyle>(doc->get_Styles()->Add(StyleType::Table, u"MyTableStyle1"));
tableStyle->get_Borders()->set_Color(System::Drawing::Color::get_Black());
tableStyle->get_Borders()->set_LineStyle(LineStyle::Double);
// Set the two colors, which will alternate over every 3 rows.
tableStyle->set_RowStripe(3);
tableStyle->get_ConditionalStyles()
->get_Shading()
->set_BackgroundPatternColor(System::Drawing::Color::get_LightBlue());
tableStyle->get_ConditionalStyles()
->get_Shading()
->set_BackgroundPatternColor(System::Drawing::Color::get_LightCyan());
// Set a color to apply to every even column, which will override any custom row coloring.
tableStyle->set_ColumnStripe(1);
tableStyle->get_ConditionalStyles()
->get_Shading()
->set_BackgroundPatternColor(System::Drawing::Color::get_LightSalmon());
table->set_Style(tableStyle);
// The "StyleOptions" property enables row banding by default.
ASSERT_EQ(TableStyleOptions::FirstRow | TableStyleOptions::FirstColumn | TableStyleOptions::RowBands, table->get_StyleOptions());
// Use the "StyleOptions" property also to enable column banding.
table->set_StyleOptions(table->get_StyleOptions() | TableStyleOptions::ColumnBands);
doc->Save(ArtifactsDir + u"Table.AlternatingRowStyles.docx");

◆ get_ConditionalStyles()

System::SharedPtr<Aspose::Words::ConditionalStyleCollection> Aspose::Words::TableStyle::get_ConditionalStyles ( )

Collection of conditional styles that may be defined for this table style.

Examples

Shows how to work with certain area styles of a table.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
SharedPtr<Table> table = builder->StartTable();
builder->InsertCell();
builder->Write(u"Cell 1");
builder->InsertCell();
builder->Write(u"Cell 2");
builder->EndRow();
builder->InsertCell();
builder->Write(u"Cell 3");
builder->InsertCell();
builder->Write(u"Cell 4");
builder->EndTable();
// Create a custom table style.
auto tableStyle = System::DynamicCast<TableStyle>(doc->get_Styles()->Add(StyleType::Table, u"MyTableStyle1"));
// Conditional styles are formatting changes that affect only some of the table's cells
// based on a predicate, such as the cells being in the last row.
// Below are three ways of accessing a table style's conditional styles from the "ConditionalStyles" collection.
// 1 - By style type:
tableStyle->get_ConditionalStyles()
->get_Shading()
->set_BackgroundPatternColor(System::Drawing::Color::get_AliceBlue());
// 2 - By index:
tableStyle->get_ConditionalStyles()->idx_get(0)->get_Borders()->set_Color(System::Drawing::Color::get_Black());
tableStyle->get_ConditionalStyles()->idx_get(0)->get_Borders()->set_LineStyle(LineStyle::DotDash);
ASSERT_EQ(ConditionalStyleType::FirstRow, tableStyle->get_ConditionalStyles()->idx_get(0)->get_Type());
// 3 - As a property:
tableStyle->get_ConditionalStyles()->get_FirstRow()->get_ParagraphFormat()->set_Alignment(ParagraphAlignment::Center);
// Apply padding and text formatting to conditional styles.
tableStyle->get_ConditionalStyles()->get_LastRow()->set_BottomPadding(10);
tableStyle->get_ConditionalStyles()->get_LastRow()->set_LeftPadding(10);
tableStyle->get_ConditionalStyles()->get_LastRow()->set_RightPadding(10);
tableStyle->get_ConditionalStyles()->get_LastRow()->set_TopPadding(10);
tableStyle->get_ConditionalStyles()->get_LastColumn()->get_Font()->set_Bold(true);
// List all possible style conditions.
{
SharedPtr<System::Collections::Generic::IEnumerator<SharedPtr<ConditionalStyle>>> enumerator = tableStyle->get_ConditionalStyles()->GetEnumerator();
while (enumerator->MoveNext())
{
SharedPtr<ConditionalStyle> currentStyle = enumerator->get_Current();
if (currentStyle != nullptr)
{
std::cout << System::EnumGetName(currentStyle->get_Type()) << std::endl;
}
}
}
// Apply the custom style, which contains all conditional styles, to the table.
table->set_Style(tableStyle);
// Our style applies some conditional styles by default.
ASSERT_EQ(TableStyleOptions::FirstRow | TableStyleOptions::FirstColumn | TableStyleOptions::RowBands, table->get_StyleOptions());
// We will need to enable all other styles ourselves via the "StyleOptions" property.
table->set_StyleOptions(table->get_StyleOptions() | TableStyleOptions::LastRow | TableStyleOptions::LastColumn);
doc->Save(ArtifactsDir + u"Table.ConditionalStyles.docx");

◆ get_LeftIndent()

double Aspose::Words::TableStyle::get_LeftIndent ( )

Gets or sets the value that represents the left indent of a table.

Examples

Shows how to set the position of a table.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Below are two ways of aligning a table horizontally.
// 1 - Use the "Alignment" property to align it to a location on the page, such as the center:
auto tableStyle = System::DynamicCast<TableStyle>(doc->get_Styles()->Add(StyleType::Table, u"MyTableStyle1"));
tableStyle->set_Alignment(TableAlignment::Center);
tableStyle->get_Borders()->set_Color(System::Drawing::Color::get_Blue());
tableStyle->get_Borders()->set_LineStyle(LineStyle::Single);
// Insert a table and apply the style we created to it.
SharedPtr<Table> table = builder->StartTable();
builder->InsertCell();
builder->Write(u"Aligned to the center of the page");
builder->EndTable();
table->set_PreferredWidth(PreferredWidth::FromPoints(300));
table->set_Style(tableStyle);
// 2 - Use the "LeftIndent" to specify an indent from the left margin of the page:
tableStyle = System::DynamicCast<TableStyle>(doc->get_Styles()->Add(StyleType::Table, u"MyTableStyle2"));
tableStyle->set_LeftIndent(55);
tableStyle->get_Borders()->set_Color(System::Drawing::Color::get_Green());
tableStyle->get_Borders()->set_LineStyle(LineStyle::Single);
table = builder->StartTable();
builder->InsertCell();
builder->Write(u"Aligned according to left indent");
builder->EndTable();
table->set_PreferredWidth(PreferredWidth::FromPoints(300));
table->set_Style(tableStyle);
doc->Save(ArtifactsDir + u"Table.SetTableAlignment.docx");

◆ get_LeftPadding()

double Aspose::Words::TableStyle::get_LeftPadding ( )

Gets or sets the amount of space (in points) to add to the left of the contents of table cells.

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::DynamicCast<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");

◆ get_RightPadding()

double Aspose::Words::TableStyle::get_RightPadding ( )

Gets or sets the amount of space (in points) to add to the right of the contents of table cells.

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::DynamicCast<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");

◆ get_RowStripe()

int32_t Aspose::Words::TableStyle::get_RowStripe ( )

Gets or sets a number of rows to include in the banding when the style specifies odd/even row banding.

Examples

Shows how to create conditional table styles that alternate between rows.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// We can configure a conditional style of a table to apply a different color to the row/column,
// based on whether the row/column is even or odd, creating an alternating color pattern.
// We can also apply a number n to the row/column banding,
// meaning that the color alternates after every n rows/columns instead of one.
// Create a table where single columns and rows will band the columns will banded in threes.
SharedPtr<Table> table = builder->StartTable();
for (int i = 0; i < 15; i++)
{
for (int j = 0; j < 4; j++)
{
builder->InsertCell();
builder->Writeln(String::Format(u"{0} column.", (j % 2 == 0 ? String(u"Even") : String(u"Odd"))));
builder->Write(String::Format(u"Row banding {0}.", (i % 3 == 0 ? String(u"start") : String(u"continuation"))));
}
builder->EndRow();
}
builder->EndTable();
// Apply a line style to all the borders of the table.
auto tableStyle = System::DynamicCast<TableStyle>(doc->get_Styles()->Add(StyleType::Table, u"MyTableStyle1"));
tableStyle->get_Borders()->set_Color(System::Drawing::Color::get_Black());
tableStyle->get_Borders()->set_LineStyle(LineStyle::Double);
// Set the two colors, which will alternate over every 3 rows.
tableStyle->set_RowStripe(3);
tableStyle->get_ConditionalStyles()
->get_Shading()
->set_BackgroundPatternColor(System::Drawing::Color::get_LightBlue());
tableStyle->get_ConditionalStyles()
->get_Shading()
->set_BackgroundPatternColor(System::Drawing::Color::get_LightCyan());
// Set a color to apply to every even column, which will override any custom row coloring.
tableStyle->set_ColumnStripe(1);
tableStyle->get_ConditionalStyles()
->get_Shading()
->set_BackgroundPatternColor(System::Drawing::Color::get_LightSalmon());
table->set_Style(tableStyle);
// The "StyleOptions" property enables row banding by default.
ASSERT_EQ(TableStyleOptions::FirstRow | TableStyleOptions::FirstColumn | TableStyleOptions::RowBands, table->get_StyleOptions());
// Use the "StyleOptions" property also to enable column banding.
table->set_StyleOptions(table->get_StyleOptions() | TableStyleOptions::ColumnBands);
doc->Save(ArtifactsDir + u"Table.AlternatingRowStyles.docx");

◆ get_Shading()

System::SharedPtr<Aspose::Words::Shading> Aspose::Words::TableStyle::get_Shading ( )

Gets a Shading object that refers to the shading formatting for table cells.

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::DynamicCast<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");

◆ get_TopPadding()

double Aspose::Words::TableStyle::get_TopPadding ( )

Gets or sets the amount of space (in points) to add above the contents of table cells.

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::DynamicCast<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");

◆ get_VerticalAlignment()

Aspose::Words::Tables::CellVerticalAlignment Aspose::Words::TableStyle::get_VerticalAlignment ( )

Specifies the vertical alignment for the cells.

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::DynamicCast<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");

◆ GetType()

virtual const System::TypeInfo& Aspose::Words::TableStyle::GetType ( ) const
overridevirtual

Reimplemented from Aspose::Words::Style.

◆ Is()

virtual bool Aspose::Words::TableStyle::Is ( const System::TypeInfo target) const
overridevirtual

Reimplemented from Aspose::Words::Style.

◆ set_Alignment()

void Aspose::Words::TableStyle::set_Alignment ( Aspose::Words::Tables::TableAlignment  value)

◆ set_AllowBreakAcrossPages()

void Aspose::Words::TableStyle::set_AllowBreakAcrossPages ( bool  value)

◆ set_Bidi()

void Aspose::Words::TableStyle::set_Bidi ( bool  value)

◆ set_BottomPadding()

void Aspose::Words::TableStyle::set_BottomPadding ( double  value)

◆ set_CellSpacing()

void Aspose::Words::TableStyle::set_CellSpacing ( double  value)

◆ set_ColumnStripe()

void Aspose::Words::TableStyle::set_ColumnStripe ( int32_t  value)

◆ set_LeftIndent()

void Aspose::Words::TableStyle::set_LeftIndent ( double  value)

◆ set_LeftPadding()

void Aspose::Words::TableStyle::set_LeftPadding ( double  value)

◆ set_RightPadding()

void Aspose::Words::TableStyle::set_RightPadding ( double  value)

◆ set_RowStripe()

void Aspose::Words::TableStyle::set_RowStripe ( int32_t  value)

◆ set_TopPadding()

void Aspose::Words::TableStyle::set_TopPadding ( double  value)

◆ set_VerticalAlignment()

void Aspose::Words::TableStyle::set_VerticalAlignment ( Aspose::Words::Tables::CellVerticalAlignment  value)

◆ Type()

static const System::TypeInfo& Aspose::Words::TableStyle::Type ( )
static