Aspose::Words::Tables::Table::get_FirstRow method
Contents
[
Hide
]Table::get_FirstRow method
Returns the first Row node in the table.
System::SharedPtr<Aspose::Words::Tables::Row> Aspose::Words::Tables::Table::get_FirstRow()
Examples
Shows how to remove the first and last rows of all tables in a document.
auto doc = System::MakeObject<Aspose::Words::Document>(get_MyDir() + u"Tables.docx");
System::SharedPtr<Aspose::Words::Tables::TableCollection> tables = doc->get_FirstSection()->get_Body()->get_Tables();
ASSERT_EQ(5, tables->idx_get(0)->get_Rows()->get_Count());
ASSERT_EQ(4, tables->idx_get(1)->get_Rows()->get_Count());
for (auto&& table : System::IterateOver(tables->LINQ_OfType<System::SharedPtr<Aspose::Words::Tables::Table> >()))
{
System::SharedPtr<Aspose::Words::Tables::Row> condExpression = table->get_FirstRow();
if (condExpression != nullptr)
{
condExpression->Remove();
}
System::SharedPtr<Aspose::Words::Tables::Row> condExpression2 = table->get_LastRow();
if (condExpression2 != nullptr)
{
condExpression2->Remove();
}
}
ASSERT_EQ(3, tables->idx_get(0)->get_Rows()->get_Count());
ASSERT_EQ(2, tables->idx_get(1)->get_Rows()->get_Count());
Shows how to combine the rows from two tables into one.
auto doc = System::MakeObject<Aspose::Words::Document>(get_MyDir() + u"Tables.docx");
// Below are two ways of getting a table from a document.
// 1 - From the "Tables" collection of a Body node:
System::SharedPtr<Aspose::Words::Tables::Table> firstTable = doc->get_FirstSection()->get_Body()->get_Tables()->idx_get(0);
// 2 - Using the "GetChild" method:
auto secondTable = System::ExplicitCast<Aspose::Words::Tables::Table>(doc->GetChild(Aspose::Words::NodeType::Table, 1, true));
// Append all rows from the current table to the next.
while (secondTable->get_HasChildNodes())
{
firstTable->get_Rows()->Add(secondTable->get_FirstRow());
}
// Remove the empty table container.
secondTable->Remove();
doc->Save(get_ArtifactsDir() + u"Table.CombineTables.docx");
See Also
- Class Row
- Class Table
- Namespace Aspose::Words::Tables
- Library Aspose.Words for C++