Search Results for

    Show / Hide Table of Contents

    Class Table

    Represents a table element within the document.

    Inheritance
    System.Object
    ContentElement
    ParentElement
    TableElements
    Table
    Implements
    IronSoftware.Abstractions.IDocumentElement
    IronSoftware.IDocumentObject
    System.ICloneable
    System.Collections.Generic.IEnumerable<TableCell>
    System.Collections.IEnumerable
    System.Collections.Generic.IEnumerable<TableRow>
    Inherited Members
    TableElements.SetBorders(TableBorders)
    TableElements.ExtractImages()
    TableElements.ExtractShapes()
    TableElements.Borders
    TableElements.BackgroundColor
    ParentElement.AddChild(ContentElement[])
    ParentElement.InsertChildToIndex(Int32, ContentElement[])
    ParentElement.Remove()
    ParentElement.RemoveChildren(ContentElement[])
    ParentElement.RemoveAllChildren()
    ParentElement.ExtractElements<T>()
    ParentElement.GetChildByIndex<T>(Int32)
    ParentElement.Clone()
    ParentElement.CloneObject()
    ParentElement.LogObjectTree()
    ParentElement.DefaultTextStyle
    ParentElement.Texts
    ParentElement.Tables
    ParentElement.Children
    ContentElement.Status
    ContentElement.Replace(ContentElement)
    ContentElement.GetIndex<T>()
    ContentElement.Parent
    ContentElement.ObjNum
    ContentElement.PageIndex
    ContentElement.DocumentId
    Namespace: IronWord.Models
    Assembly: IronWord.dll
    Syntax
    public class Table : TableElements, IDocumentElement, IDocumentObject, ICloneable, IEnumerable<TableCell>, IEnumerable, IEnumerable<TableRow>

    Constructors

    Table()

    Initializes a new instance of the Table class.

    Declaration
    public Table()

    Table(TableRow[])

    Initializes a new instance of the Table class with the specified rows.

    Declaration
    public Table(params TableRow[] rows)
    Parameters
    Type Name Description
    TableRow[] rows

    The table rows to be added.

    Table(Int32, Int32)

    Initializes a new instance of the Table class with the specified number of rows and columns.

    Declaration
    public Table(int row, int column)
    Parameters
    Type Name Description
    System.Int32 row

    The number of rows in the table.

    System.Int32 column

    The number of columns in each row of the table.

    Properties

    Columns

    Gets the list of TableColumn elements contained within this table. Thread-safe implementation with double-checked locking for performance.

    Declaration
    public List<TableColumn> Columns { get; }
    Property Value
    Type Description
    System.Collections.Generic.List<TableColumn>

    Data

    Raw data

    Declaration
    public DataTable Data { get; }
    Property Value
    Type Description
    System.Data.DataTable

    Direction

    Gets or sets the Direction of the table

    Declaration
    public Direction Direction { get; set; }
    Property Value
    Type Description
    Direction

    Index

    Gets the index of this table within the parent's list of children.

    Declaration
    public int Index { get; set; }
    Property Value
    Type Description
    System.Int32

    Item[Int32]

    Gets or sets the TableRow at the specified row index.

    Declaration
    public TableRow this[int row] { get; set; }
    Parameters
    Type Name Description
    System.Int32 row

    The index of the row.

    Property Value
    Type Description
    TableRow

    The TableRow at the specified row index.

    Exceptions
    Type Condition
    System.IndexOutOfRangeException

    Thrown when the specified row index is out of range.

    Item[Int32, Int32]

    Gets or sets the TableCell at the specified row and column indices.

    Declaration
    public TableCell this[int row, int column] { get; set; }
    Parameters
    Type Name Description
    System.Int32 row

    The index of the row.

    System.Int32 column

    The index of the column.

    Property Value
    Type Description
    TableCell

    The TableCell at the specified row and column indices.

    Exceptions
    Type Condition
    System.IndexOutOfRangeException

    Thrown when the specified row or column index is out of range.

    MergedCells

    Gets a list of cell merges applied to the table.

    Declaration
    public List<MergeCell> MergedCells { get; set; }
    Property Value
    Type Description
    System.Collections.Generic.List<MergeCell>

    Rows

    Gets the list of TableRow elements contained within this table. Thread-safe implementation with caching for performance.

    Declaration
    public List<TableRow> Rows { get; }
    Property Value
    Type Description
    System.Collections.Generic.List<TableRow>

    Shading

    Gets or sets the Sets the color of the shading and fill of the table.

    Declaration
    public Shading Shading { get; set; }
    Property Value
    Type Description
    Shading

    Style

    Gets or sets the Style of the table

    Declaration
    public TableStyle Style { get; set; }
    Property Value
    Type Description
    TableStyle

    Width

    Gets or sets the width of the table.

    Declaration
    public double Width { get; set; }
    Property Value
    Type Description
    System.Double

    Zebra

    Gets or sets the pair of colors used for applying zebra background to table rows.

    Declaration
    public ZebraColor Zebra { get; set; }
    Property Value
    Type Description
    ZebraColor

    Methods

    AddColumn()

    Adds a new column to the table.

    Declaration
    public Table AddColumn()
    Returns
    Type Description
    Table

    AddRow(TableRow)

    Initializes a new instance of the Table class with the specified row.

    Declaration
    public Table AddRow(TableRow row)
    Parameters
    Type Name Description
    TableRow row

    The table row to be added.

    Returns
    Type Description
    Table

    GetCell(Int32, Int32)

    Gets the TableCell at the specified row and column indices.

    Declaration
    public TableCell GetCell(int row, int column)
    Parameters
    Type Name Description
    System.Int32 row

    The index of the row containing the desired TableCell.

    System.Int32 column

    The index of the column containing the desired TableCell.

    Returns
    Type Description
    TableCell

    The TableCell at the specified row and column indices.

    GetCellValue(Int32, Int32)

    Gets the contents of a specific cell within the table.

    Declaration
    public List<ContentElement> GetCellValue(int rowIndex, int columnIndex)
    Parameters
    Type Name Description
    System.Int32 rowIndex

    The row index of the cell.

    System.Int32 columnIndex

    The column index of the cell.

    Returns
    Type Description
    System.Collections.Generic.List<ContentElement>

    A list of ContentElement objects representing the cell's content.

    GetEnumerator()

    Provides an enumerator that iterates through all TableCell elements in the table, traversing rows and cells.

    Declaration
    public IEnumerator<TableCell> GetEnumerator()
    Returns
    Type Description
    System.Collections.Generic.IEnumerator<TableCell>

    An enumerator for the table cells.

    GetRow(Int32)

    Gets the TableRow at the specified row indices.

    Declaration
    public TableRow GetRow(int row)
    Parameters
    Type Name Description
    System.Int32 row

    The index of the row in this table.

    Returns
    Type Description
    TableRow

    The TableCell at the specified row and column indices.

    GetWidth(MeasurementUnit)

    Gets the width of the Table in the specified measurement unit.

    Declaration
    public double GetWidth(MeasurementUnit measurementUnit)
    Parameters
    Type Name Description
    MeasurementUnit measurementUnit

    The measurement unit for the width. Default is twentieths of a point (Twips).

    Returns
    Type Description
    System.Double

    The width of the Table in the specified measurement unit.

    MergeCells(Int32, Int32, Int32, Int32)

    Merges a range of cells within the table.

    Declaration
    public Table MergeCells(int startRow, int startColumn, int endRow, int endColumn)
    Parameters
    Type Name Description
    System.Int32 startRow

    The starting row index of the merged area (inclusive).

    System.Int32 startColumn

    The starting column index of the merged area (inclusive).

    System.Int32 endRow

    The ending row index of the merged area (inclusive).

    System.Int32 endColumn

    The ending column index of the merged area (inclusive).

    Returns
    Type Description
    Table

    RemoveColumn(Int32)

    Removes a column from the table.

    Declaration
    public Table RemoveColumn(int index)
    Parameters
    Type Name Description
    System.Int32 index

    The index of the column to be removed.

    Returns
    Type Description
    Table

    RemoveRow(Int32)

    Removes a row from the table.

    Declaration
    public Table RemoveRow(int index)
    Parameters
    Type Name Description
    System.Int32 index

    The index of the row to be removed.

    Returns
    Type Description
    Table

    SetCellValue(Int32, Int32, ContentElement)

    Sets the content of a specific cell within the table.

    Declaration
    public Table SetCellValue(int row, int column, ContentElement content)
    Parameters
    Type Name Description
    System.Int32 row

    The row index of the cell.

    System.Int32 column

    The column index of the cell.

    ContentElement content

    The ContentElement object representing the new content for the cell.

    Returns
    Type Description
    Table

    SetWidth(Double, MeasurementUnit)

    Sets the width of the table.

    Declaration
    public Table SetWidth(double width, MeasurementUnit measurementUnit)
    Parameters
    Type Name Description
    System.Double width

    The width value to set.

    MeasurementUnit measurementUnit

    The measurement unit of the provided height. Default is twentieths of a point (Twips).

    Returns
    Type Description
    Table

    Split(Int32, Int32, Int32, Int32)

    Splits a cell in the table into multiple rows and columns.

    Declaration
    public Table Split(int row, int column, int toRow, int toColumn)
    Parameters
    Type Name Description
    System.Int32 row

    The index of the starting row to split.

    System.Int32 column

    The index of the starting column to split.

    System.Int32 toRow

    The number of the row for the split.

    System.Int32 toColumn

    The number of columns for the split.

    Returns
    Type Description
    Table

    Implements

    IronSoftware.Abstractions.IDocumentElement
    IronSoftware.IDocumentObject
    System.ICloneable
    System.Collections.Generic.IEnumerable<>
    System.Collections.IEnumerable
    System.Collections.Generic.IEnumerable<>

    Inherited members

    SetBorders(TableBorders)
    ExtractImages()
    ExtractShapes()
    Borders
    BackgroundColor
    AddChild(ContentElement[])
    InsertChildToIndex(Int32, ContentElement[])
    Remove()
    RemoveChildren(ContentElement[])
    RemoveAllChildren()
    ExtractElements<T>()
    GetChildByIndex<T>(Int32)
    Clone()
    CloneObject()
    LogObjectTree()
    DefaultTextStyle
    Texts
    Tables
    Children
    Status
    Replace(ContentElement)
    GetIndex<T>()
    Parent
    ObjNum
    PageIndex
    DocumentId
    ☀
    ☾
    Downloads
    • Download with NuGet
    • Start for Free
    In This Article
    Back to top
    Install with NuGet
    Want to deploy IronWord to a live project for FREE?
    What’s included?
    30 days of fully-functional product
    Test and share in a live environment
    No watermarks in production
    Get your free 30-day Trial Key instantly.
    No credit card or account creation required
    Your Trial License Key has been emailed to you.
    Download IronWord free to apply
    your Trial Licenses Key
    Install with NuGet View Licenses
    Licenses from $499. Have a question? Get in touch.