TableStyleOptions enumeration

TableStyleOptions enumeration

Specifies how table style is applied to a table.

Members

NameDescription
NoneNo table style formatting is applied.
FirstRowApply first row conditional formatting.
LastRowApply last row conditional formatting.
FirstColumnApply 1 first column conditional formatting.
LastColumnApply last column conditional formatting.
RowBandsApply row banding conditional formatting.
ColumnBandsApply column banding conditional formatting.
Default2003Row and column banding is applied. This is Microsoft Word default for old formats such as DOC, WML and RTF.
DefaultThis is Microsoft Word defaults.

Examples

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

let doc = new aw.Document();
let builder = new aw.DocumentBuilder(doc);
let 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.styleIdentifier = aw.StyleIdentifier.MediumShading1Accent1;

// Partially apply the style to features of the table based on predicates, then build the table.
table.styleOptions =
  aw.Tables.TableStyleOptions.FirstColumn | aw.Tables.TableStyleOptions.RowBands | aw.Tables.TableStyleOptions.FirstRow;
table.autoFit(aw.Tables.AutoFitBehavior.AutoFitToContents);

builder.writeln("Item");
builder.cellFormat.rightPadding = 40;
builder.insertCell();
builder.writeln("Quantity (kg)");
builder.endRow();

builder.insertCell();
builder.writeln("Apples");
builder.insertCell();
builder.writeln("20");
builder.endRow();

builder.insertCell();
builder.writeln("Bananas");
builder.insertCell();
builder.writeln("40");
builder.endRow();

builder.insertCell();
builder.writeln("Carrots");
builder.insertCell();
builder.writeln("50");
builder.endRow();

doc.save(base.artifactsDir + "DocumentBuilder.InsertTableWithStyle.docx");

See Also