Method ApplyTableStyle
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
documentWordDocumentThe document that holds the table.
tableTableThe table.
definitionStyleThe style (a table style; its id names it), added as a copy when the document has no style of that id.
basedOnStyleThe 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,tableordefinitionis 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.