ParagraphIsEndOfCell Property

True if this paragraph is the last paragraph in a Cell; false otherwise.

Namespace:  Aspose.Words
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 20.10.0


public bool IsEndOfCell { get; }

Property Value

Type: Boolean


Shows how to set a table to stay together on the same page.
Document doc = new Document(MyDir + "Table spanning two pages.docx");
Table table = (Table)doc.GetChild(NodeType.Table, 0, true);

// Enabling KeepWithNext for every paragraph in the table except for the last ones in the last row
// will prevent the table from being split across pages 
foreach (Cell cell in table.GetChildNodes(NodeType.Cell, true).OfType<Cell>())
    foreach (Paragraph para in cell.Paragraphs.OfType<Paragraph>())

        if (!(cell.ParentRow.IsLastRow && para.IsEndOfCell))
            para.ParagraphFormat.KeepWithNext = true;

doc.Save(ArtifactsDir + "Table.KeepTableTogether.docx");

ExpandedSee Also