Aspose::Words::Tables::Row::get_IsLastRow method
Contents
[
Hide
]Row::get_IsLastRow method
True if this is the last row in a table; false otherwise.
bool Aspose::Words::Tables::Row::get_IsLastRow()
Examples
Shows how to set a table to stay together on the same page.
auto doc = MakeObject<Document>(MyDir + u"Table spanning two pages.docx");
SharedPtr<Table> table = doc->get_FirstSection()->get_Body()->get_Tables()->idx_get(0);
// Enabling KeepWithNext for every paragraph in the table except for the
// last ones in the last row will prevent the table from splitting across multiple pages.
for (const auto& cell : System::IterateOver(table->GetChildNodes(NodeType::Cell, true)->LINQ_OfType<SharedPtr<Cell>>()))
{
for (const auto& para : System::IterateOver(cell->get_Paragraphs()->LINQ_OfType<SharedPtr<Paragraph>>()))
{
ASSERT_TRUE(para->get_IsInCell());
if (!(cell->get_ParentRow()->get_IsLastRow() && para->get_IsEndOfCell()))
{
para->get_ParagraphFormat()->set_KeepWithNext(true);
}
}
}
doc->Save(ArtifactsDir + u"Table.KeepTableTogether.docx");
See Also
- Class Row
- Namespace Aspose::Words::Tables
- Library Aspose.Words for C++