Table of Contents

Method ApplyTableStyle

Namespace
DocWright.Dom.Editing
Assembly
DocWright.Dom.dll

ApplyTableStyle(WordDocument, Table, Style, Style?)

Applies a table style as Word's Table Design gallery does (WQ-0122), adding its definition when the document lacks it: the table takes the style and Word's style options (header row, first column, banded rows: w:tblLook 04A0), and loses its own borders and its cells' shading and borders, which would hide the style's. Text formatting in the cells stays. One edit, which also takes away a definition it added.

public static DocumentEdit ApplyTableStyle(this WordDocument document, Table table, Style definition, Style? basedOn = null)

Parameters

document WordDocument

The document that holds the table.

table Table

The table.

definition Style

The style (a table style; its id names it), added as a copy when the document has no style of that id.

basedOn Style

The style it is based on, added as a copy too when the document lacks it, or null.

Returns

DocumentEdit

The edit; the caret stays at the table's first cell.

Exceptions

ArgumentNullException

document, table or definition is null.

ArgumentException

The table is not in the document, a definition is not a table style, or the document's style of that id is not one.