Aspose::Words::Tables::TableStyleOptions enum

TableStyleOptions enum

Specifies how table style is applied to a table.

enum class TableStyleOptions

Values

NameValueDescription
None0No table style formatting is applied.
FirstRow32Apply first row conditional formatting.
LastRow64Apply last row conditional formatting.
FirstColumn128Apply 1 first column conditional formatting.
LastColumn256Apply last column conditional formatting.
RowBands512Apply row banding conditional formatting.
ColumnBands1024Apply column banding conditional formatting.
Default2003n/aRow and column banding is applied. This is Microsoft Word default for old formats such as DOC, WML and RTF.
Defaultn/aThis is Microsoft Word defaults.

Examples

Shows how to build a new table while applying a style.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
SharedPtr<Table> table = builder->StartTable();

// We must insert at least one row before setting any table formatting.
builder->InsertCell();

// Set the table style used based on the style identifier.
// Note that not all table styles are available when saving to .doc format.
table->set_StyleIdentifier(StyleIdentifier::MediumShading1Accent1);

// Partially apply the style to features of the table based on predicates, then build the table.
table->set_StyleOptions(TableStyleOptions::FirstColumn | TableStyleOptions::RowBands | TableStyleOptions::FirstRow);
table->AutoFit(AutoFitBehavior::AutoFitToContents);

builder->Writeln(u"Item");
builder->get_CellFormat()->set_RightPadding(40);
builder->InsertCell();
builder->Writeln(u"Quantity (kg)");
builder->EndRow();

builder->InsertCell();
builder->Writeln(u"Apples");
builder->InsertCell();
builder->Writeln(u"20");
builder->EndRow();

builder->InsertCell();
builder->Writeln(u"Bananas");
builder->InsertCell();
builder->Writeln(u"40");
builder->EndRow();

builder->InsertCell();
builder->Writeln(u"Carrots");
builder->InsertCell();
builder->Writeln(u"50");
builder->EndRow();

doc->Save(ArtifactsDir + u"DocumentBuilder.InsertTableWithStyle.docx");

See Also