Xamarin.Android

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class WTableRow

    Show / Hide Table of Contents

    Class WTableRow

    Represents a table row.

    Inheritance
    System.Object
    OwnerHolder
    XDLSSerializableBase
    Entity
    WidgetBase
    WTableRow
    Implements
    IXDLSSerializable
    ICompositeEntity
    IEntity
    Inherited Members
    Entity.Owner
    Entity.NextSibling
    Entity.PreviousSibling
    Entity.IsComposite
    XDLSSerializableBase.IXDLSSerializable.WriteXmlAttributes(IXDLSAttributeWriter)
    XDLSSerializableBase.IXDLSSerializable.WriteXmlContent(IXDLSContentWriter)
    XDLSSerializableBase.IXDLSSerializable.ReadXmlAttributes(IXDLSAttributeReader)
    XDLSSerializableBase.IXDLSSerializable.ReadXmlContent(IXDLSContentReader)
    XDLSSerializableBase.IXDLSSerializable.RestoreReference(String, Int32)
    XDLSSerializableBase.RestoreReference(String, Int32)
    XDLSSerializableBase.IXDLSSerializable.XDLSHolder
    XDLSSerializableBase.XDLSHolder
    OwnerHolder.m_doc
    OwnerHolder.Document
    Namespace: Syncfusion.DocIO.DLS
    Assembly: Syncfusion.DocIO.Portable.dll
    Syntax
    public class WTableRow : WidgetBase, IXDLSSerializable, IWidget, ICompositeEntity, IEntity

    Constructors

    WTableRow(IWordDocument)

    Initializes a new instance of the WTableRow class with the specified IWordDocument instance.

    Declaration
    public WTableRow(IWordDocument document)
    Parameters
    Type Name Description
    IWordDocument document

    The IWordDocument instance.

    Properties

    Cells

    Gets or sets the collection of cells in the row.

    Declaration
    public WCellCollection Cells { get; set; }
    Property Value
    Type Description
    WCellCollection

    The WCellCollection that represents the cells in the row.

    See Also
    WTableCell

    ChildEntities

    Gets the child elements of the row. Read-only

    Declaration
    public EntityCollection ChildEntities { get; }
    Property Value
    Type Description
    EntityCollection

    The collection of child elements.

    EntityType

    Gets the type of the entity.

    Declaration
    public override EntityType EntityType { get; }
    Property Value
    Type Description
    EntityType

    The EntityType of the current item.

    Overrides
    Entity.EntityType

    Height

    Gets or sets height of the row(in points).

    Declaration
    public float Height { get; set; }
    Property Value
    Type Description
    System.Single

    The float that specifies the row height.

    Examples

    The following example illustrates how to set the height of the row in the table.

    private void Button1_Click(System.Object sender, System.EventArgs e)
    {
        //Create a new Word document
        WordDocument document = new WordDocument();
        IWSection section = document.AddSection();
        //Add a new table into Word document
        IWTable table = section.AddTable();
        //Set number of rows and columns
        table.ResetCells(2, 2);
        //Set row height and type.
        table.Rows[1].Height = 20;
        table.Rows[1].HeightType = TableRowHeightType.AtLeast;
        //Save and close the document
        document.Save("Sample.docx", FormatType.Docx);
        document.Close();
    }
    Private Sub button_Click(sender As Object, e As EventArgs)
        'Create a new Word document
        Dim document As New WordDocument()
        Dim section As IWSection = document.AddSection()
        'Add a new table into Word document
        Dim table As IWTable = section.AddTable()
        'Set number of rows and columns
        table.ResetCells(2, 2)
        'Set row height and type.
        table.Rows(1).Height = 20
        table.Rows(1).HeightType = TableRowHeightType.AtLeast
        'Save and close the document
        document.Save("Sample.docx", FormatType.Docx)
        document.Close()
    End Sub

    HeightType

    Gets or sets the type of the table row height.

    Declaration
    public TableRowHeightType HeightType { get; set; }
    Property Value
    Type Description
    TableRowHeightType

    The TableRowHeightType member that specifies the type of row height.

    See Also
    Height

    IsHeader

    Gets or sets a value indicating whether the row is a table header.

    Declaration
    public bool IsHeader { get; set; }
    Property Value
    Type Description
    System.Boolean

    True if the row is header row; otherwise, false.

    RowFormat

    Gets the row format. Read-only.

    Declaration
    public RowFormat RowFormat { get; }
    Property Value
    Type Description
    RowFormat
    See Also
    RowFormat

    Methods

    AddCell()

    Adds a new cell to the row.

    Declaration
    public WTableCell AddCell()
    Returns
    Type Description
    WTableCell

    The reference to the newly added cell.

    Examples

    The following example illustrates how to add a cell to the row.

    private void Button1_Click(System.Object sender, System.EventArgs e)
    {
        WordDocument document = new WordDocument();
        IWSection section = document.AddSection();
        section.AddParagraph().AppendText("Price Details");
        section.AddParagraph();
        //Add a new table into Word document
        IWTable table = section.AddTable();
        //Add the first row into table
        WTableRow row = table.AddRow();
        //Add the first cell into first row 
        WTableCell cell = row.AddCell();
        cell.Width = 100;
        cell.AddParagraph().AppendText("Orange");
        //Add the second cell into first row 
        cell = row.AddCell();
        cell.Width = 100;
        cell.AddParagraph().AppendText("$30");
        //Add the second row into table
        row = table.AddRow(true, false);
        //Add the first cell into second row
        cell = row.AddCell();
        cell.Width = 100;
        cell.AddParagraph().AppendText("Apple");
        //Add the second cell into second row
        cell = row.AddCell();
        cell.Width = 100;
        cell.AddParagraph().AppendText("$50");     
        //Save and close the document
        document.Save("Sample.docx", FormatType.Docx);
        document.Close();
    }
    Private Sub button_Click(sender As Object, e As EventArgs)
        Dim document As New WordDocument()
        Dim section As IWSection = document.AddSection()
        section.AddParagraph().AppendText("Price Details")
        section.AddParagraph()
        'Add a new table into Word document
        Dim table As IWTable = section.AddTable()
        'Add the first row into table
        Dim row As WTableRow = table.AddRow()
        'Add the first cell into first row 
        Dim cell As WTableCell = row.AddCell()
        cell.Width = 100
        cell.AddParagraph().AppendText("Orange")
        'Add the second cell into first row 
        cell = row.AddCell()
        cell.Width = 100
        cell.AddParagraph().AppendText("$30")
        'Add the second row into table
        row = table.AddRow(True, False)
        'Add the first cell into second row
        cell = row.AddCell()
        cell.Width = 100
        cell.AddParagraph().AppendText("Apple")
        'Add the second cell into second row
        cell = row.AddCell()
        cell.Width = 100
        cell.AddParagraph().AppendText("$50")
        'Save and close the document
        document.Save("Sample.docx", FormatType.Docx)
        document.Close()
    End Sub

    AddCell(Boolean)

    Adds a new cell to the row.

    Declaration
    public WTableCell AddCell(bool isCopyFormat)
    Parameters
    Type Name Description
    System.Boolean isCopyFormat

    True if to have format of the previous row; otherwise, false.

    Returns
    Type Description
    WTableCell

    The reference to the newly added cell.

    Examples

    The following example illustrates how to add a cell to the row by specifying the copy format option.

    private void Button1_Click(System.Object sender, System.EventArgs e)
    {
        WordDocument document = new WordDocument();
        IWSection section = document.AddSection();
        section.AddParagraph().AppendText("Price Details");
        section.AddParagraph();
        //Add a new table into Word document
        IWTable table = section.AddTable();
        //Add the first row into table
        WTableRow row = table.AddRow();
        //Add the first cell into first row 
        WTableCell cell = row.AddCell();
        cell.Width = 100;
        cell.AddParagraph().AppendText("Orange");
        //Add the second cell into first row 
        cell = row.AddCell();
        cell.Width = 100;
        cell.AddParagraph().AppendText("$30");
        //Add the second row into table
        row = table.AddRow(true, false);
        //Add the first cell into second row
        cell = row.AddCell();
        cell.Width = 50;
        cell.AddParagraph().AppendText("Apple");
        //Add the second cell into second row
        cell = row.AddCell(true);
        cell.AddParagraph().AppendText("$50");     
        //Save and close the document
        document.Save("Sample.docx", FormatType.Docx);
        document.Close();
    }
    Private Sub button_Click(sender As Object, e As EventArgs)
        Dim document As New WordDocument()
        Dim section As IWSection = document.AddSection()
        section.AddParagraph().AppendText("Price Details")
        section.AddParagraph()
        'Add a new table into Word document
        Dim table As IWTable = section.AddTable()
        'Add the first row into table
        Dim row As WTableRow = table.AddRow()
        'Add the first cell into first row 
        Dim cell As WTableCell = row.AddCell()
        cell.Width = 100
        cell.AddParagraph().AppendText("Orange")
        'Add the second cell into first row 
        cell = row.AddCell()
        cell.Width = 100
        cell.AddParagraph().AppendText("$30")
        'Add the second row into table
        row = table.AddRow(True, False)
        'Add the first cell into second row
        cell = row.AddCell()
        cell.Width = 50
        cell.AddParagraph().AppendText("Apple")
        'Add the second cell into second row
        cell = row.AddCell(True)
        cell.AddParagraph().AppendText("$50")
        'Save and close the document
        document.Save("Sample.docx", FormatType.Docx)
        document.Close()
    End Sub
    Exceptions
    Type Condition
    System.ArgumentException

    The number of cells must be between 1 and 63.

    Clone()

    Creates a duplicate copy of the entity.

    Declaration
    public WTableRow Clone()
    Returns
    Type Description
    WTableRow

    The reference to the newly created row.

    CloneImpl()

    Creates a duplicate copy of the entity.

    Declaration
    protected override object CloneImpl()
    Returns
    Type Description
    System.Object

    An System.Object that can be casted as WTableRow.

    Overrides
    XDLSSerializableBase.CloneImpl()

    GetRowIndex()

    Returns the index of the row in the table.

    Declaration
    public int GetRowIndex()
    Returns
    Type Description
    System.Int32

    The zero-based index of the row.

    Examples
    private void Button1_Click(System.Object sender, System.EventArgs e)
    {
        //Load a template document
        WordDocument document = new WordDocument("Template.docx");
        //Get the table
        WTable table = document.Sections[0].Tables[0] as WTable;
        //Find the text in the table
        TextSelection selection = table.Find(new Regex("Cell"));
        WTextRange text = selection.GetAsOneRange();
        //Get the owner paragraph
        WParagraph paragraph = text.OwnerParagraph;
        //Get the owner cell
        WTableCell cell = paragraph.OwnerTextBody as WTableCell;
        //Get the row index.
        int index = cell.OwnerRow.GetRowIndex();
        //Set height for next row
        table.Rows[index + 1].Height = 20;
        //Save and close the document
        document.Save("Sample.docx", FormatType.Docx);
        document.Close();
    }
    Private Sub button_Click(sender As Object, e As EventArgs)
        'Load a template document
        Dim document As New WordDocument("Template.docx")
        'Get the table
        Dim table As WTable = TryCast(document.Sections(0).Tables(0), WTable)
        'Find the text in the table
        Dim selection As TextSelection = table.Find(New Regex("Cell"))
        Dim text As WTextRange = selection.GetAsOneRange()
        'Get the owner paragraph
        Dim paragraph As WParagraph = text.OwnerParagraph
        'Get the owner cell
        Dim cell As WTableCell = TryCast(paragraph.OwnerTextBody, WTableCell)
        'Get the row index.
        Dim index As Integer = cell.OwnerRow.GetRowIndex()
        'Set height for next row
        table.Rows(index + 1).Height = 20
        'Save and close the document
        document.Save("Sample.docx", FormatType.Docx)
        document.Close()
    End Sub

    InitXDLSHolder()

    Registers child objects in XDSL holder.

    Declaration
    protected override void InitXDLSHolder()
    Overrides
    XDLSSerializableBase.InitXDLSHolder()

    ReadXmlAttributes(IXDLSAttributeReader)

    Reads object data from xml attributes.

    Declaration
    protected override void ReadXmlAttributes(IXDLSAttributeReader reader)
    Parameters
    Type Name Description
    IXDLSAttributeReader reader

    The IXDLSAttributeReader object.

    Overrides
    XDLSSerializableBase.ReadXmlAttributes(IXDLSAttributeReader)

    ReadXmlContent(IXDLSContentReader)

    Reads object data from xml attributes.

    Declaration
    protected override bool ReadXmlContent(IXDLSContentReader reader)
    Parameters
    Type Name Description
    IXDLSContentReader reader

    The IXDLSContentReader object.

    Returns
    Type Description
    System.Boolean

    The value indicating the presence of xml content.

    Overrides
    XDLSSerializableBase.ReadXmlContent(IXDLSContentReader)

    WriteXmlAttributes(IXDLSAttributeWriter)

    Writes object data as xml attributes.

    Declaration
    protected override void WriteXmlAttributes(IXDLSAttributeWriter writer)
    Parameters
    Type Name Description
    IXDLSAttributeWriter writer

    The IXDLSAttributeWriter object.

    Overrides
    XDLSSerializableBase.WriteXmlAttributes(IXDLSAttributeWriter)

    WriteXmlContent(IXDLSContentWriter)

    Writes object data as inside xml element.

    Declaration
    protected override void WriteXmlContent(IXDLSContentWriter writer)
    Parameters
    Type Name Description
    IXDLSContentWriter writer

    The IXDLSContentWriter object.

    Overrides
    XDLSSerializableBase.WriteXmlContent(IXDLSContentWriter)

    Implements

    IXDLSSerializable
    ICompositeEntity
    IEntity
    Back to top Generated by DocFX
    Copyright © 2001 - 2023 Syncfusion Inc. All Rights Reserved