Search Results for

    Show / Hide Table of Contents

    Class MergeCell

    Represents a range of cells that are merged into a single cell.

    Inheritance
    System.Object
    MergeCell
    Namespace: IronWord.Models
    Assembly: IronWord.dll
    Syntax
    public class MergeCell : Object

    When two or more table cells should read as one, a MergeCell records the rectangular block they span. It captures the corner coordinates of a merge so a table can present a single combined cell, the pattern behind a header that stretches across columns or a label that runs down several rows.

    A merge is defined by four zero-based coordinates: StartRow and StartColumn mark the top-left cell of the block, and EndRow and EndColumn mark the bottom-right. The range between those corners becomes the merged region. In practice you do not build the geometry by hand for every case; a Table exposes MergeCells, which takes the same start-row, start-column, end-row, and end-column arguments and performs the merge, while the table's MergedCells property lists the MergeCell records already applied. Reading that list tells you which regions of an existing table are combined.

    Set the four coordinates to cover the block you want, keeping the start corner above and to the left of the end corner, then let the table apply it. Because the values are zero-based, the first row and first column are index 0, so a header spanning the first three columns of the top row runs from (0, 0) to (0, 2). Once merged, the cells behave as the single cell at the start corner, which is where content for the region is read and written through GetCell. The cells absorbed into the block no longer hold their own content, so populate the start cell after the merge rather than before. A table can carry several merges at once, each its own MergeCell record, which is how a layout combines a banner row and a stacked label column in the same grid.

    table.MergeCells(0, 0, 0, 2);

    The add table example builds a table, the add table how-to walks through cells and layout in detail, and the document element tutorial places tables within a document.

    Constructors

    MergeCell()

    Declaration
    public MergeCell()

    Properties

    EndColumn

    Gets or sets the ending column index of the merged cell.

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

    EndRow

    Gets or sets the ending row index of the merged cell.

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

    StartColumn

    Gets or sets the starting column index of the merged cell.

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

    StartRow

    Gets or sets the starting row index of the merged cell.

    Declaration
    public int StartRow { get; set; }
    Property Value
    Type Description
    System.Int32
    ☀
    ☾
    Downloads
    • Download with NuGet
    • Start for Free
    In This Article
    Back to top
    Install with NuGet