Search Results for

    Show / Hide Table of Contents

    Class TableRow

    Represents a row element within a table.

    Inheritance
    System.Object
    ContentElement
    ParentElement
    TableElement
    TableRow
    Implements
    IronSoftware.Abstractions.Word.ITableRow
    IronSoftware.Abstractions.Word.IWordDocumentObject
    IronSoftware.Abstractions.IDocumentObject
    System.ICloneable
    IronSoftware.Abstractions.IParent<IronSoftware.Abstractions.Word.IWordDocumentObjectCollection, IronSoftware.Abstractions.Word.IWordDocumentObject>
    System.Collections.Generic.IEnumerable<IronSoftware.Abstractions.Word.ITableCell>
    System.Collections.IEnumerable
    Inherited Members
    TableElement.ExtractImages()
    TableElement.ExtractShapes()
    TableElement.Borders
    TableElement.BackgroundColor
    ParentElement.AddChild(IWordDocumentObject[])
    ParentElement.InsertChildToIndex(Int32, IWordDocumentObject[])
    ParentElement.Remove()
    ParentElement.RemoveChildren(IWordDocumentObject[])
    ParentElement.RemoveAllChildren()
    ParentElement.ExtractElements<T>()
    ParentElement.GetChildByIndex<T>(Int32)
    ParentElement.Clone()
    ParentElement.CloneObject()
    ParentElement.LogObjectTree()
    ParentElement.Texts
    ParentElement.Tables
    ParentElement.Children
    ContentElement.Replace(IWordDocumentObject)
    ContentElement.GetIndex<T>()
    ContentElement.Parent
    ContentElement.Status
    Namespace: IronWord.Models
    Assembly: IronWord.dll
    Syntax
    public class TableRow : TableElement

    TableRow is the horizontal band of cells you assemble when building a Word table row by row. Each instance holds an ordered list of TableCell objects and the row's height, and a Table exposes its rows for reading and editing. Use it when a table is built incrementally, adding one populated row at a time rather than sizing the whole grid up front.

    Create a row empty (new TableRow()) or from cells (new TableRow(params TableCell[])), then add it to a table with Table.AddRow. The cells inside a row are reachable through the Cells list and through the row's indexer, row[index], and AddCell appends a TableCell to the end. Because TableRow is enumerable, GetEnumerator and a foreach walk its cells directly, which is handy when filling or reading a row in a loop.

    Row height is controlled by the Height property, and GetHeight and SetHeight read and write it in a chosen MeasurementUnit. Index reports the row's position within the table, and InsertRowAfterSelf and InsertRowBeforeSelf add a neighbouring row relative to this one, so rows can be spliced in without rebuilding the table. The usual pattern is to build a TableRow with its cells, set the height if it matters, and hand it to the table. Building a table row by row is the natural approach when the row count is not known up front, such as turning a list of records into a table where each record becomes one row. After a row is added, it stays reachable through Table.Rows, so a later pass can adjust its height or read its cells.

    using IronWord.Models;
    
    TableRow row = new TableRow();
    row.AddCell(new TableCell("Number"));
    row.AddCell(new TableCell("Name"));
    
    Table table = new Table();
    table.AddRow(row);

    The add a table how-to covers building tables from rows and cells, the add table example iterates rows to populate a grid, and the document element tutorial covers how rows sit in the document model.

    Constructors

    TableRow()

    Initializes a new instance of the TableRow class.

    Declaration
    public TableRow()

    TableRow(TableCell[])

    Initializes a new instance of the TableRow class with the specified cells.

    Declaration
    public TableRow(params TableCell[] cells)
    Parameters
    Type Name Description
    TableCell[] cells

    The table cells to be added.

    Properties

    Cells

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

    Declaration
    public List<ITableCell> Cells { get; }
    Property Value
    Type Description
    System.Collections.Generic.List<IronSoftware.Abstractions.Word.ITableCell>

    Height

    Gets or sets the height of the table row in inches. The height is internally stored in EMU (English Metric Units) and converted to inches for display. Setting this property will automatically convert the inch value to EMU for internal storage.

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

    Index

    The index of this table row within the parent table.

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

    Item[Int32]

    Gets or sets the table cell at the specified column index within the row.

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

    The index of the column within the row.

    Property Value
    Type Description
    IronSoftware.Abstractions.Word.ITableCell

    The table cell at the specified column index.

    Methods

    AddCell(TableCell)

    Adds a new TableCell to the row.

    Declaration
    public void AddCell(TableCell cell)
    Parameters
    Type Name Description
    TableCell cell

    The TableCell object to be added to the row.

    CloneStruct()

    Creates and returns a new instance of TableRow with the same structure (number of cells and their structure) as the current row.

    Declaration
    public TableRow CloneStruct()
    Returns
    Type Description
    TableRow

    A cloned TableRow with the same structure as the current row.

    GetEnumerator()

    Returns an enumerator that iterates through the collection of TableCell elements in the row.

    Declaration
    public IEnumerator<ITableCell> GetEnumerator()
    Returns
    Type Description
    System.Collections.Generic.IEnumerator<IronSoftware.Abstractions.Word.ITableCell>

    An enumerator that can be used to iterate through the collection of TableCell elements in the row.

    GetHeight(MeasurementUnit)

    Gets the height of the table row in the specified measurement unit. The height is internally stored in EMU and converted to the requested unit.

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

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

    Returns
    Type Description
    System.Double

    The height of the table row in the specified measurement unit.

    InsertRowAfterSelf()

    Inserts a new TableRow after this row within the parent table with the same structure (number of cells and their structure) as the current row.

    Declaration
    public void InsertRowAfterSelf()

    InsertRowAfterSelf(ITableRow)

    Declaration
    public void InsertRowAfterSelf(ITableRow row)
    Parameters
    Type Name Description
    IronSoftware.Abstractions.Word.ITableRow row

    InsertRowBeforeSelf()

    Inserts a new TableRow before this row within the parent table with the same structure (number of cells and their structure) as the current row.

    Declaration
    public void InsertRowBeforeSelf()

    InsertRowBeforeSelf(ITableRow)

    Declaration
    public void InsertRowBeforeSelf(ITableRow row)
    Parameters
    Type Name Description
    IronSoftware.Abstractions.Word.ITableRow row

    SetHeight(Double, MeasurementUnit)

    Sets the height of the table row. The height value will be converted to EMU for internal storage.

    Declaration
    public void SetHeight(double height, MeasurementUnit measurementUnit)
    Parameters
    Type Name Description
    System.Double height

    The height value to set.

    MeasurementUnit measurementUnit

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

    Implements

    IronSoftware.Abstractions.Word.ITableRow
    IronSoftware.Abstractions.Word.IWordDocumentObject
    IronSoftware.Abstractions.IDocumentObject
    System.ICloneable
    IronSoftware.Abstractions.IParent<, >
    System.Collections.Generic.IEnumerable<>
    System.Collections.IEnumerable

    Inherited members

    ExtractImages()
    ExtractShapes()
    Borders
    BackgroundColor
    AddChild(IWordDocumentObject[])
    InsertChildToIndex(Int32, IWordDocumentObject[])
    Remove()
    RemoveChildren(IWordDocumentObject[])
    RemoveAllChildren()
    ExtractElements<T>()
    GetChildByIndex<T>(Int32)
    Clone()
    CloneObject()
    LogObjectTree()
    Texts
    Tables
    Children
    Replace(IWordDocumentObject)
    GetIndex<T>()
    Parent
    Status
    ☀
    ☾
    Downloads
    • Download with NuGet
    • Start for Free
    In This Article
    Back to top
    Install with NuGet
    IronWord_for_dotnet_log2o
    Blue key in circleGet started for FREE
    No credit card required
    Test in a live environment

    Test in production without watermarks.
    Works wherever you need it to.

    Fully-functional product

    Get 30 days of fully functional product.
    Have it up and running in minutes.

    24/5 technical support

    Full access to our support engineering team during your product trial

    Grey key in circleGet started for FREE
    The trial form was submitted successfully.
    Calendar in circleBook Free Live Demo
    No contact, no card details, no commitments Book a 30-minute, personal demo.
    Here's what to expect:

    A live demo of our product and its key features

    Get project specific feature recommendations

    All your questions are answered to make sure you have all the information you need. (No commitment whatsoever.)

    Grey key in circleBook Free Live Demo
    Your booking has been completed Check your e-mail for confirmation
    Support Team Member 6 related to The C# PDF Library Support Team Member 14 related to The C# PDF Library Support Team Member 4 related to The C# PDF Library Support Team Member 2 related to The C# PDF Library
    Online 24/5
    Need help? Our sales team would be glad to help you.
    Try the Enterprise Trial
    ironpdf_for_dotnet_log2o
    Key in blue circle
    Get your free 30-day Trial Key instantly.
    bullet_checkedNo credit card or account creation required
    Key in blue circle
    Get your free 30-day Trial Key instantly.
    Blue key in circleNo credit card or account creation required
    Green Check in orange circle
    The trial form was submitted successfully.
    badge_greencheck_in_yellowcircle
    Thank you for starting a trial

    Please check your email for the trial license key.

    If you don’t receive an email, please start a live chat or email support@ironsoftware.com

    Install with NuGet
    View Licensing
    • Logo Aetna
    • Logo NASA
    • Logo GE
    • Logo Porsche
    • Logo USDA
    • Logo Qatar
    Join Millions of Engineers who’ve tried IronWord