API Reference
WordTable
Represents a table within a WordDocument.
Inheritance
- WordElement
- WordTable
Usage
This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.
Returned or exposed by
- Method WordFluentDocument.Tables
- Property WordTableBuilder.Table
- Method WordDocument.AddTable
- Method WordDocument.AddTableFromObjects
- Method WordDocument.CreateTable
- Method WordDocument.InsertTableAfter
- Property WordDocument.Tables
- Property WordDocument.TablesIncludingNestedTables
- Method WordFooter.AddTable
- Property WordFooter.Tables
- Method WordHeader.AddTable
- Property WordHeader.Tables
- Method WordHeaderFooter.AddTable
- Property WordHeaderFooter.Tables
- Method WordParagraph.AddTableAfter
- Method WordParagraph.AddTableBefore
- Method WordSection.AddTable
- Property WordSection.Tables
- Property WordSection.TablesIncludingNestedTables
- Method WordTable.Clone
- Method WordTable.Clone
- Method WordTable.Clone
- Method WordTable.CloneAfterSelf
- Method WordTable.CloneBeforeSelf
- Method WordTable.Create
- Method WordTable.SetStyleId
- Property WordTable.NestedTables
- Property WordTable.ParentTable
- Method WordTableCell.AddTable
- Property WordTableCell.NestedTables
- Property WordTableCell.ParentTable
- Property WordTableRow.Parent
Accepted by parameters
- Method FooterContentBuilder.Table
- Method HeaderContentBuilder.Table
- Method WordDocument.InsertTableAfter
- Method WordMailMerge.ExecuteTableRowGroups
- Method WordMailMerge.ExecuteTableRows
- Method WordTable.Clone
- Constructor WordTableCell.WordTableCell
- Constructor WordTableRow.WordTableRow
Methods
public Void AddComment(String author, String initials, String comment) #VoidAdd comment to a Table
Parameters
- author System.String
- Provide an author of the comment
- initials System.String
- Provide initials of an author
- comment System.String
- Provide comment to insert
public WordTableRow AddRow(Int32 cellsCount = 0) #WordTableRowAdd row to an existing table with the specified number of columns
Parameters
- cellsCount System.Int32 = 0
public List<WordTableRow> AddRow(Int32 rowsCount, Int32 cellsCount) #List<WordTableRow>Add specified number of rows to an existing table with the specified number of columns
Parameters
- rowsCount System.Int32
- cellsCount System.Int32
public WordTableConditionalFormattingBuilder BeginConditionalFormatting() #WordTableConditionalFormattingBuilderStarts building conditional formatting rules using a fluent API.
Returns
public WordTable Clone() #WordTableCreates a deep copy of the current table and inserts it after the table.
Returns
The newly cloned WordTable.
Examples
WordTable clone = table.Clone();
public WordTable Clone(WordParagraph paragraph, Boolean after = true) #WordTableClones the table and inserts it relative to the specified paragraph.
Parameters
- paragraph OfficeIMO.Word.WordParagraph
- Reference paragraph for insertion.
- after System.Boolean = true
- If true inserts after the paragraph, otherwise before.
Returns
The cloned WordTable.
Examples
WordTable copy = table.Clone(paragraph, after: false);
public WordTable Clone(WordTable table, Boolean after = true) #WordTableClones the table and inserts it relative to another table.
Parameters
- table OfficeIMO.Word.WordTable
- Reference table for insertion.
- after System.Boolean = true
- If true inserts after the table, otherwise before.
Returns
The cloned WordTable.
Examples
WordTable copy = table1.Clone(table2, after: true);
public WordTable CloneAfterSelf() #WordTableClones the table and inserts the clone after the current table.
Returns
The cloned WordTable.
Examples
WordTable copy = table.CloneAfterSelf();
public WordTable CloneBeforeSelf() #WordTableClones the table and inserts the clone before the current table.
Returns
The cloned WordTable.
Examples
WordTable copy = table.CloneBeforeSelf();
public Void ConditionalFormatting(String columnName, String matchText, WordTextMatchType matchType, String matchFillColorHex = null, String matchFontColorHex = null, String noMatchFillColorHex = null, String noMatchFontColorHex = null, Boolean ignoreCase = true, IEnumerable<String> highlightColumns = null, Action<WordParagraph> matchTextFormat = null, Action<WordParagraph> noMatchTextFormat = null) #VoidApplies conditional formatting to cells based on text contained in a specific column.
Parameters
- columnName System.String
- Header text of the column to evaluate.
- matchText System.String
- Text to compare against cell content.
- matchType OfficeIMO.Word.WordTextMatchType
- Comparison operator.
- matchFillColorHex System.String = null
- Background color applied when condition is met.
- matchFontColorHex System.String = null
- Font color applied when condition is met.
- noMatchFillColorHex System.String = null
- Background color applied when condition is not met.
- noMatchFontColorHex System.String = null
- Font color applied when condition is not met.
- ignoreCase System.Boolean = true
- Whether comparison should ignore case.
- highlightColumns System.Collections.Generic.IEnumerable{System.String} = null
- Additional columns to apply the formatting to.
- matchTextFormat System.Action{OfficeIMO.Word.WordParagraph} = null
- Optional action applied to paragraphs when the condition is met.
- noMatchTextFormat System.Action{OfficeIMO.Word.WordParagraph} = null
- Optional action applied to paragraphs when the condition is not met.
public Void ConditionalFormatting(String columnName, String matchText, WordTextMatchType matchType, OfficeColor matchFillColor, Nullable<OfficeColor> matchFontColor = null, Nullable<OfficeColor> noMatchFillColor = null, Nullable<OfficeColor> noMatchFontColor = null, Boolean ignoreCase = true, IEnumerable<String> highlightColumns = null, Action<WordParagraph> matchTextFormat = null, Action<WordParagraph> noMatchTextFormat = null) #VoidApplies conditional formatting to cells using OfficeColor parameters.
Parameters
- columnName System.String
- Header text of the column to evaluate.
- matchText System.String
- Text to compare against cell content.
- matchType OfficeIMO.Word.WordTextMatchType
- Comparison operator.
- matchFillColor OfficeIMO.Drawing.OfficeColor
- Background color applied when condition is met.
- matchFontColor System.Nullable{OfficeIMO.Drawing.OfficeColor} = null
- Font color applied when condition is met.
- noMatchFillColor System.Nullable{OfficeIMO.Drawing.OfficeColor} = null
- Background color applied when condition is not met.
- noMatchFontColor System.Nullable{OfficeIMO.Drawing.OfficeColor} = null
- Font color applied when condition is not met.
- ignoreCase System.Boolean = true
- Whether comparison should ignore case.
- highlightColumns System.Collections.Generic.IEnumerable{System.String} = null
- Additional columns to apply the formatting to.
- matchTextFormat System.Action{OfficeIMO.Word.WordParagraph} = null
- Optional action applied to paragraphs when the condition is met.
- noMatchTextFormat System.Action{OfficeIMO.Word.WordParagraph} = null
- Optional action applied to paragraphs when the condition is not met.
public Void ConditionalFormatting(IEnumerable<ValueTuple<String, String, WordTextMatchType>> conditions, Boolean matchAll, String matchFillColorHex = null, String matchFontColorHex = null, String noMatchFillColorHex = null, String noMatchFontColorHex = null, Boolean ignoreCase = true, IEnumerable<String> highlightColumns = null, Action<WordParagraph> matchTextFormat = null, Action<WordParagraph> noMatchTextFormat = null) #VoidApplies conditional formatting based on values in multiple columns.
Parameters
- conditions System.Collections.Generic.IEnumerable{System.ValueTuple{System.String,System.String,OfficeIMO.Word.WordTextMatchType}}
- List of column/value conditions.
- matchAll System.Boolean
- When true, all conditions must match; otherwise any condition can match.
- matchFillColorHex System.String = null
- Background color applied when conditions match.
- matchFontColorHex System.String = null
- Font color applied when conditions match.
- noMatchFillColorHex System.String = null
- Background color applied when conditions do not match.
- noMatchFontColorHex System.String = null
- Font color applied when conditions do not match.
- ignoreCase System.Boolean = true
- Whether comparison should ignore case.
- highlightColumns System.Collections.Generic.IEnumerable{System.String} = null
- Columns to apply the formatting to. Defaults to the columns used in conditions.
- matchTextFormat System.Action{OfficeIMO.Word.WordParagraph} = null
- Optional action applied to paragraphs when conditions match.
- noMatchTextFormat System.Action{OfficeIMO.Word.WordParagraph} = null
- Optional action applied to paragraphs when conditions do not match.
public Void ConditionalFormatting(IEnumerable<ValueTuple<String, String, WordTextMatchType>> conditions, Boolean matchAll, OfficeColor matchFillColor, Nullable<OfficeColor> matchFontColor = null, Nullable<OfficeColor> noMatchFillColor = null, Nullable<OfficeColor> noMatchFontColor = null, Boolean ignoreCase = true, IEnumerable<String> highlightColumns = null, Action<WordParagraph> matchTextFormat = null, Action<WordParagraph> noMatchTextFormat = null) #VoidApplies conditional formatting based on values in multiple columns using OfficeColor parameters.
Parameters
- conditions System.Collections.Generic.IEnumerable{System.ValueTuple{System.String,System.String,OfficeIMO.Word.WordTextMatchType}}
- List of column/value conditions.
- matchAll System.Boolean
- When true, all conditions must match; otherwise any condition can match.
- matchFillColor OfficeIMO.Drawing.OfficeColor
- Background color applied when conditions match.
- matchFontColor System.Nullable{OfficeIMO.Drawing.OfficeColor} = null
- Font color applied when conditions match.
- noMatchFillColor System.Nullable{OfficeIMO.Drawing.OfficeColor} = null
- Background color applied when conditions do not match.
- noMatchFontColor System.Nullable{OfficeIMO.Drawing.OfficeColor} = null
- Font color applied when conditions do not match.
- ignoreCase System.Boolean = true
- Whether comparison should ignore case.
- highlightColumns System.Collections.Generic.IEnumerable{System.String} = null
- Columns to apply the formatting to. Defaults to the columns used in conditions.
- matchTextFormat System.Action{OfficeIMO.Word.WordParagraph} = null
- Optional action applied to paragraphs when conditions match.
- noMatchTextFormat System.Action{OfficeIMO.Word.WordParagraph} = null
- Optional action applied to paragraphs when conditions do not match.
public Void ConditionalFormatting(Func<WordTableRow, Boolean> predicate, Action<WordTableRow> matchAction, Action<WordTableRow> noMatchAction = null) #VoidApplies conditional formatting based on a custom row predicate.
Parameters
- predicate System.Func{OfficeIMO.Word.WordTableRow,System.Boolean}
- Condition evaluated for each data row.
- matchAction System.Action{OfficeIMO.Word.WordTableRow}
- Action executed when predicate is true.
- noMatchAction System.Action{OfficeIMO.Word.WordTableRow} = null
- Action executed when predicate is false.
public WordTableRow CopyRow(WordTableRow row) #WordTableRowCopy existing WordTableRow and inserts it as a last row in a Table
Parameters
- row OfficeIMO.Word.WordTableRow
public static WordTable Create(WordDocument document, Int32 rows, Int32 columns, WordTableStyle tableStyle = TableGrid) #WordTableCreates a table instance without inserting it into the document.
Parameters
- document OfficeIMO.Word.WordDocument
- Parent WordDocument.
- rows System.Int32
- Number of rows.
- columns System.Int32
- Number of columns.
- tableStyle OfficeIMO.Word.WordTableStyle = TableGrid
- Style to apply to the table.
Returns
The newly created WordTable.
public Void DistributeColumnsEvenly() #VoidDistribute columns evenly by setting their size to the same value based on the current table width settings (or 100% Pct if not set).
public Void MergeCells(Int32 rowIndex, Int32 columnIndex, Int32 rowSpan, Int32 colSpan, Boolean copyParagraphs = false) #VoidMerges a rectangular range of cells.
Parameters
- rowIndex System.Int32
- Zero-based starting row index.
- columnIndex System.Int32
- Zero-based starting column index.
- rowSpan System.Int32
- Number of rows spanned by the merged region.
- colSpan System.Int32
- Number of columns spanned by the merged region.
- copyParagraphs System.Boolean = false
- If set to true, paragraphs from merged cells are copied into the first cell.
public Void NormalizeForOnline() #VoidNormalizes this table for online viewers by updating tblGrid only. Does not change authoring semantics (tblW, width type, positioning). Skips pure-Auto tables (keeps Word's native behavior): - no table preferred width (or Auto), - no column width type set, - and all cells carry only the library's default tcW (DXA 2400).
public Void SetColumnWidthsPercentage(params Int32[] percentages) #VoidSets column widths using percentages. Values are scaled proportionally when they don't sum to 100.
Parameters
- percentages System.Int32[]
- Column percentages in any positive ratio.
public Void SetFixedWidth(Int32 percentage) #VoidSets the table to Fixed Width with the specified percentage
Parameters
- percentage System.Int32
- Width percentage (0-100)
public WordTable SetStyleId(String styleId) #WordTableApplies a table style defined in the document.
Parameters
- styleId System.String
- Identifier of the table style to apply.
Returns
The current WordTable instance.
public Void SetWidthPercentage(Int32 percentage) #VoidSets the table width to a percentage of the window width
Parameters
- percentage System.Int32
- Width percentage (0-100)
Inherited Methods
public override Boolean Equals(Object obj) #BooleanParameters
- obj Object
Properties
public List<WordParagraph> Paragraphs { get; } #Gets all WordParagraph instances contained in the table.
public Boolean AllowRowToBreakAcrossPages { get; set; } #Allow row to break across pages This sets each row to allow page break You can set each row separately as well Getting value returns true if any row allows page break For complete control use WordTableRow.AllowRowToBreakAcrossPages
public Boolean RepeatAsHeaderRowAtTheTopOfEachPage { get; set; } #Allow Header to repeat on each page This applies to only header of the table (first row)
public Nullable<WordTableStyle> Style { get; set; } #Gets or sets the built-in table style applied to this table. Returns null when no style is assigned.
public Nullable<WordTableAlignment> Alignment { get; set; } #Gets or sets the horizontal alignment of the table within the page.
public Nullable<WordTableWidthUnit> WidthType { get; set; } #Gets or sets the unit type used by the Width property.
public Nullable<Int32> Width { get; set; } #Gets or sets width of a table
public Nullable<Boolean> ConditionalFormattingFirstRow { get; set; } #Specifies that the first row conditional formatting shall be applied to the table.
public Nullable<Boolean> ConditionalFormattingLastRow { get; set; } #Specifies that the last row conditional formatting shall be applied to the table.
public Nullable<Boolean> ConditionalFormattingFirstColumn { get; set; } #Specifies that the first column conditional formatting shall be applied to the table.
public Nullable<Boolean> ConditionalFormattingLastColumn { get; set; } #Specifies that the last column conditional formatting shall be applied to the table.
public Nullable<Boolean> ConditionalFormattingNoHorizontalBand { get; set; } #Specifies that the horizontal banding conditional formatting shall not be applied to the table.
public Nullable<Boolean> ConditionalFormattingNoVerticalBand { get; set; } #Specifies that the vertical banding conditional formatting shall not be applied to the table.
public Boolean RepeatHeaderRowAtTheTopOfEachPage { get; set; } #Specifies that the first row shall be repeated at the top of each page on which the table is displayed.
public Int32 RowsCount { get; } #Gets the number of rows in the table.
public List<WordTableRow> Rows { get; } #Gets the collection of rows belonging to the table.
public WordTableRow FirstRow { get; } #Gets the first row of the table.
public WordTableRow LastRow { get; } #Gets the last row of the table.
public WordTablePosition Position { get; } #Provides positioning information for the table within the document.
public WordTableStyleDetails StyleDetails { get; } #Gets the table style details. WIP
public String Title { get; set; } #Gets or sets a Title/Caption to a Table
public String Description { get; set; } #Gets or sets Description for a Table
public Boolean AllowOverlap { get; set; } #Allow table to overlap or not
public WordTableLayoutMode LayoutMode { get; set; } #Gets or sets the layout algorithm used by Word for the table. Changing the algorithm preserves the table and cell preferred widths. Use AutoFitToWindow or Int32) when the width should also change.
public Boolean AllowTextWrap { get; set; } #Allow text to wrap around table.
public Boolean WrapText { get; set; } #Gets or sets whether text wraps within all cells of the table.
public Boolean FitText { get; set; } #Gets or sets whether text is compressed to fit within all cells of the table.
public List<Int32> GridColumnWidth { get; set; } #Sets or gets grid columns width (not really doing anything as far as I can see)
public List<Int32> ColumnWidth { get; set; } #Gets or sets column width for a whole table simplifying setup of column width Please note that it assumes first row has the same width as the rest of rows which may give false positives if there are multiple values set differently.
public Nullable<WordTableWidthUnit> ColumnWidthType { get; set; } #Gets or sets the column width type for a whole table simplifying setup of column width
public List<Int32> RowHeight { get; set; } #Get or set row heights for the table
public List<WordTableCell> Cells { get; } #Get all WordTableCells in a table. A short way to loop thru all cells
public Boolean HasNestedTables { get; } #Gets information whether the Table has other nested tables in at least one of the TableCells
public List<WordTable> NestedTables { get; } #Get all nested tables in the table
public Boolean IsNestedTable { get; } #Gets information whether the table is nested table (within TableCell)
public WordTable ParentTable { get; } #Gets nested table parent table if table is nested table
public List<WordStructuredDocumentTag> StructuredDocumentTags { get; } #Gets all structured document tags contained in the table.
public List<WordCheckBox> CheckBoxes { get; } #Gets all checkbox content controls contained in the table.
public List<WordDatePicker> DatePickers { get; } #Gets all date picker content controls contained in the table.
public List<WordDropDownList> DropDownLists { get; } #Gets all dropdown list content controls contained in the table.
public List<WordRepeatingSection> RepeatingSections { get; } #Gets all repeating section content controls contained in the table.