Aspose::Words::Tables::Cell Class Reference

Detailed Description

Represents a table cell.

Cell can only be a child of a Row.

Cell can contain block-level nodes Paragraph and Table.

A minimal valid cell needs to have at least one Paragraph.

Examples

Shows how to create a simple table.

auto doc = MakeObject<Document>();
// Tables are placed in the body of a document
auto table = MakeObject<Table>(doc);
doc->get_FirstSection()->get_Body()->AppendChild(table);
// Tables contain rows, which contain cells,
// which contain contents such as paragraphs, runs and even other tables
// Calling table.EnsureMinimum will also make sure that a table has at least one row, cell and paragraph
auto firstRow = MakeObject<Row>(doc);
table->AppendChild(firstRow);
auto firstCell = MakeObject<Cell>(doc);
firstRow->AppendChild(firstCell);
auto paragraph = MakeObject<Paragraph>(doc);
firstCell->AppendChild(paragraph);
auto run = MakeObject<Run>(doc, u"Hello world!");
paragraph->AppendChild(run);
doc->Save(ArtifactsDir + u"Table.CreateTable.docx");

Shows how to iterate through all tables in the document and display the content from each cell.

auto doc = MakeObject<Document>(MyDir + u"Tables.docx");
// Here we get all tables from the Document node. You can do this for any other composite node
// which can contain block level nodes. For example you can retrieve tables from header or from a cell
// containing another table (nested tables)
SharedPtr<TableCollection> tables = doc->get_FirstSection()->get_Body()->get_Tables();
// We can make a new array to clone all of the tables in the collection
ASSERT_EQ(2, tables->ToArray()->get_Length());
// Iterate through all tables in the document
for (int i = 0; i < tables->get_Count(); i++)
{
// Get the index of the table node as contained in the parent node of the table
System::Console::WriteLine(String::Format(u"Start of Table {0}",i));
SharedPtr<RowCollection> rows = tables->idx_get(i)->get_Rows();
// RowCollections can be cloned into arrays
ASPOSE_ASSERT_EQ(rows, rows->ToArray());
ASPOSE_ASSERT_NS(rows, rows->ToArray());
// Iterate through all rows in the table
for (int j = 0; j < rows->get_Count(); j++)
{
System::Console::WriteLine(String::Format(u"\tStart of Row {0}",j));
SharedPtr<CellCollection> cells = rows->idx_get(j)->get_Cells();
// RowCollections can also be cloned into arrays
ASPOSE_ASSERT_EQ(cells, cells->ToArray());
ASPOSE_ASSERT_NS(cells, cells->ToArray());
// Iterate through all cells in the row
for (int k = 0; k < cells->get_Count(); k++)
{
// Get the plain text content of this cell
String cellText = cells->idx_get(k)->ToString(Aspose::Words::SaveFormat::Text).Trim();
// Print the content of the cell
System::Console::WriteLine(String::Format(u"\t\tContents of Cell:{0} = \"{1}\"",k,cellText));
}
System::Console::WriteLine(String::Format(u"\tEnd of Row {0}",j));
}
System::Console::WriteLine(String::Format(u"End of Table {0}\n",i));
}

#include <Aspose.Words.Cpp/Model/Tables/Cell.h>

+ Inheritance diagram for Aspose::Words::Tables::Cell:

Public Member Functions

 Cell (SharedPtr< DocumentBase > doc)
 Initializes a new instance of the Cell class. More...
 
bool Accept (SharedPtr< DocumentVisitor > visitor) override
 Accepts a visitor. More...
 
void EnsureMinimum ()
 If the last child is not a paragraph, creates and appends one empty paragraph. More...
 
SharedPtr< CellFormatget_CellFormat ()
 Provides access to the formatting properties of the cell. More...
 
SharedPtr< Paragraphget_FirstParagraph ()
 Gets the first paragraph among the immediate children. More...
 
bool get_IsFirstCell ()
 True if this is the first cell inside a row; false otherwise. More...
 
bool get_IsLastCell ()
 True if this is the last cell inside a row; false otherwise. More...
 
SharedPtr< Paragraphget_LastParagraph ()
 Gets the last paragraph among the immediate children. More...
 
NodeType get_NodeType () const override
 Returns NodeType.Cell. More...
 
SharedPtr< ParagraphCollectionget_Paragraphs ()
 Gets a collection of paragraphs that are immediate children of the cell. More...
 
SharedPtr< Rowget_ParentRow ()
 Returns the parent row of the cell. More...
 
SharedPtr< TableCollectionget_Tables ()
 Gets a collection of tables that are immediate children of the cell. More...
 
virtual const TypeInfoGetType () const override
 
virtual bool Is (const TypeInfo &target) const override
 
- Public Member Functions inherited from CompositeNode
SharedPtr< NodeAppendChild (SharedPtr< Node > newChild)
 Adds the specified node to the end of the list of child nodes for this node. More...
 
SharedPtr< NodeCollectionget_ChildNodes ()
 Gets all immediate child nodes of this node. More...
 
SharedPtr< CompositeNodeget_Container () override
 
int32_t get_Count ()
 Gets the number of immediate children of this node. More...
 
SharedPtr< Nodeget_FirstChild () const
 Gets the first child of the node. More...
 
bool get_HasChildNodes ()
 Returns true if this node has any child nodes. More...
 
bool get_IsComposite () override
 Returns true as this node can have child nodes. More...
 
SharedPtr< Nodeget_LastChild () const
 Gets the last child of the node. More...
 
SharedPtr< NodeGetChild (NodeType nodeType, int32_t index, bool isDeep)
 Returns an Nth child node that matches the specified type. More...
 
SharedPtr< NodeCollectionGetChildNodes (NodeType nodeType, bool isDeep)
 Returns a live collection of child nodes that match the specified type. More...
 
SharedPtr< NodeGetCurrentNode () override
 
SharedPtr< IEnumerator< SharedPtr< Node > > > GetEnumerator () override
 Provides support for the for each style iteration over the child nodes of this node. More...
 
SharedPtr< NodeGetNextMatchingNode (SharedPtr< Node > curNode) override
 
String GetText () override
 Gets the text of this node and of all its children. More...
 
int32_t IndexOf (SharedPtr< Node > child)
 Returns the index of the specified child node in the child node array. More...
 
SharedPtr< NodeInsertAfter (SharedPtr< Node > newChild, SharedPtr< Node > refChild)
 Inserts the specified node immediately after the specified reference node. More...
 
SharedPtr< NodeInsertBefore (SharedPtr< Node > newChild, SharedPtr< Node > refChild)
 Inserts the specified node immediately before the specified reference node. More...
 
SharedPtr< NodePrependChild (SharedPtr< Node > newChild)
 Adds the specified node to the beginning of the list of child nodes for this node. More...
 
void RemoveAllChildren ()
 Removes all the child nodes of the current node. More...
 
SharedPtr< NodeRemoveChild (SharedPtr< Node > oldChild)
 Removes the specified child node. More...
 
void RemoveSmartTags ()
 Removes all SmartTag descendant nodes of the current node. More...
 
SharedPtr< NodeListSelectNodes (String xpath)
 Selects a list of nodes matching the XPath expression. More...
 
SharedPtr< NodeSelectSingleNode (String xpath)
 Selects the first Node that matches the XPath expression. More...
 
- Public Member Functions inherited from Node
SharedPtr< NodeClone (bool isCloneChildren)
 
virtual SharedPtr< DocumentBaseget_Document () const
 Gets the document to which this node belongs. More...
 
SharedPtr< Nodeget_NextSibling ()
 Gets the node immediately following this node. More...
 
SharedPtr< CompositeNodeget_ParentNode ()
 Gets the immediate parent of this node. More...
 
SharedPtr< Nodeget_PreviousSibling ()
 Gets the node immediately preceding this node. More...
 
SharedPtr< Rangeget_Range ()
 Returns a Range object that represents the portion of a document that is contained in this node. More...
 
SharedPtr< CompositeNodeGetAncestor (NodeType ancestorType)
 Gets the first ancestor of the specified NodeType. More...
 
template<typename T >
GetAncestorOf ()
 
SharedPtr< NodeNextPreOrder (SharedPtr< Node > rootNode)
 Gets next node according to the pre-order tree traversal algorithm. More...
 
SharedPtr< NodePreviousPreOrder (SharedPtr< Node > rootNode)
 Gets the previous node according to the pre-order tree traversal algorithm. More...
 
void Remove ()
 Removes itself from the parent. More...
 
String ToString (SaveFormat saveFormat)
 Exports the content of the node into a string in the specified format. More...
 
String ToString (SharedPtr< SaveOptions > saveOptions)
 Exports the content of the node into a string using the specified save options. More...
 
- Public Member Functions inherited from Object
ASPOSECPP_SHARED_API Object ()
 
ASPOSECPP_SHARED_API Object (Object const &x)
 
virtual ASPOSECPP_SHARED_API ~Object ()
 
virtual ASPOSECPP_SHARED_API bool Equals (ptr obj)
 
Detail::SmartPtrCounter * GetCounter ()
 
virtual ASPOSECPP_SHARED_API int GetHashCode () const
 
ASPOSECPP_SHARED_API void Lock ()
 
virtual ASPOSECPP_SHARED_API ptr MemberwiseClone () const
 
Objectoperator= (Object const &x)
 
bool ReferenceEquals (String const &str, std::nullptr_t)
 
bool ReferenceEquals (String const &str1, String const &str2)
 
int RemovedSharedRefs (int count)
 
virtual ASPOSECPP_SHARED_API void SetTemplateWeakPtr (unsigned int argument)
 
int SharedCount () const
 
ObjectSharedRefAdded ()
 
int SharedRefRemovedSafe ()
 
virtual ASPOSECPP_SHARED_API String ToString () const
 
ASPOSECPP_SHARED_API void Unlock ()
 
Detail::SmartPtrCounter * WeakRefAdded ()
 
void WeakRefRemoved ()
 
- Public Member Functions inherited from System::Collections::Generic::IEnumerable< System::SharedPtr< Aspose::Words::Node > >
EnumeratorBasedIterator< T, IEnumerator< T > > begin () noexcept
 
EnumeratorBasedIterator< T, IEnumerator< T > > cbegin () noexcept
 
EnumeratorBasedIterator< T, IEnumerator< T > > cend () noexcept
 
EnumeratorBasedIterator< T, IEnumerator< T > > end () noexcept
 
bool LINQ_All (std::function< bool(T)> predicate)
 
bool LINQ_Any ()
 
bool LINQ_Any (std::function< bool(T)> predicate)
 
SharedPtr< IEnumerable< ResultType > > LINQ_Cast ()
 
SharedPtr< IEnumerable< Result > > LINQ_Cast ()
 
bool LINQ_Contains (T value)
 
int LINQ_Count ()
 
int LINQ_Count (const Func< T, bool > &predicate)
 
LINQ_ElementAt (int index)
 
LINQ_First ()
 
LINQ_First (const Func< T, bool > &predicate)
 
LINQ_FirstOrDefault ()
 
LINQ_FirstOrDefault (std::function< bool(T)> predicate)
 
LINQ_Last ()
 
LINQ_LastOrDefault ()
 
SharedPtr< IEnumerable< ResultType > > LINQ_OfType ()
 
SharedPtr< IEnumerable< Result > > LINQ_OfType ()
 
SharedPtr< IEnumerable< Source > > LINQ_OrderBy (const Func< Source, Key > &keySelector)
 
SharedPtr< IEnumerable< T > > LINQ_OrderBy (const Func< T, Key > &keySelector)
 
SharedPtr< IEnumerable< Result > > LINQ_Select (const Func< Source, Result > &selector)
 
SharedPtr< IEnumerable< ResultType > > LINQ_Select (const Func< T, ResultType > &selector)
 
ArrayPtr< T > LINQ_ToArray ()
 
SharedPtr< List< T > > LINQ_ToList ()
 
SharedPtr< IEnumerable< T > > LINQ_Where (std::function< bool(T)> predicate)
 

Static Public Member Functions

static const TypeInfoType ()
 
- Static Public Member Functions inherited from CompositeNode
static const TypeInfoType ()
 
- Static Public Member Functions inherited from Node
static String NodeTypeToString (NodeType nodeType)
 A utility method that converts a node type enum value into a user friendly string. More...
 
static const TypeInfoType ()
 
- Static Public Member Functions inherited from Object
bool Equals (double const &objA, double const &objB)
 
bool Equals (float const &objA, float const &objB)
 
static std::enable_if<!IsSmartPtr< T1 >::value &&!IsSmartPtr< T2 >::value, bool >::type Equals (T1 const &objA, T2 const &objB)
 
static std::enable_if< IsSmartPtr< T1 >::value &&IsSmartPtr< T2 >::value, bool >::type Equals (T1 const &objA, T2 const &objB)
 
static bool ReferenceEquals (ptr const &objA, ptr const &objB)
 
static std::enable_if<!IsSmartPtr< T >::value, bool >::type ReferenceEquals (T const &objA, std::nullptr_t)
 
static std::enable_if<!IsSmartPtr< T >::value, bool >::type ReferenceEquals (T const &objA, T const &objB)
 
static const TypeInfoType ()
 

Additional Inherited Members

- Public Types inherited from Object
typedef SmartPtr< Objectptr
 
typedef System::Details::SharedMembersType shared_members_type
 
- Public Types inherited from System::Collections::Generic::IEnumerable< System::SharedPtr< Aspose::Words::Node > >
typedef IEnumerator< T > IEnumeratorType
 
typedef T ValueType
 

Constructor & Destructor Documentation

◆ Cell()

Aspose::Words::Tables::Cell::Cell ( System::SharedPtr< Aspose::Words::DocumentBase doc)

Initializes a new instance of the Cell class.

When Cell is created, it belongs to the specified document, but is not yet part of the document and ParentNode is null.

To append Cell to the document use InsertAfter or InsertBefore on the row where you want the cell inserted.

Parameters
docThe owner document.

Member Function Documentation

◆ Accept()

bool Aspose::Words::Tables::Cell::Accept ( System::SharedPtr< Aspose::Words::DocumentVisitor visitor)
overridevirtual

Accepts a visitor.

Enumerates over this node and all of its children. Each node calls a corresponding method on DocumentVisitor.

For more info see the Visitor design pattern.

Parameters
visitorThe visitor that will visit the nodes.
Returns
True if all nodes were visited; false if DocumentVisitor stopped the operation before visiting all nodes.

Implements Aspose::Words::Node.

◆ EnsureMinimum()

void Aspose::Words::Tables::Cell::EnsureMinimum ( )

If the last child is not a paragraph, creates and appends one empty paragraph.

Examples

Shows how to ensure a cell node is valid.

auto doc = MakeObject<Document>();
// Create a new table and add it to the document
auto table = MakeObject<Table>(doc);
doc->get_FirstSection()->get_Body()->AppendChild(table);
// Create a new row with a new cell and append it to the table
auto row = MakeObject<Row>(doc);
table->AppendChild(row);
auto cell = MakeObject<Cell>(doc);
row->AppendChild(cell);
// Currently, the cell does not contain any cells or nodes that can have content added to them
ASSERT_EQ(0, cell->GetChildNodes(Aspose::Words::NodeType::Any, true)->get_Count());
// Ensure the cell has at least one paragraph that we can edit
cell->EnsureMinimum();
cell->get_FirstParagraph()->AppendChild(MakeObject<Run>(doc, u"Hello world!"));

◆ get_CellFormat()

System::SharedPtr<Aspose::Words::Tables::CellFormat> Aspose::Words::Tables::Cell::get_CellFormat ( )

Provides access to the formatting properties of the cell.

Examples

Shows how to modify the format of rows and cells.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
SharedPtr<Table> table = builder->StartTable();
builder->InsertCell();
builder->Write(u"City");
builder->InsertCell();
builder->Write(u"Country");
builder->EndRow();
builder->InsertCell();
builder->Write(u"London");
builder->InsertCell();
builder->Write(u"U.K.");
builder->EndTable();
// The appearance of rows and individual cells can be edited using the respective formatting objects
SharedPtr<Aspose::Words::Tables::RowFormat> rowFormat = table->get_FirstRow()->get_RowFormat();
rowFormat->set_Height(25);
rowFormat->get_Borders()->idx_get(Aspose::Words::BorderType::Bottom)->set_Color(System::Drawing::Color::get_Red());
SharedPtr<Aspose::Words::Tables::CellFormat> cellFormat = table->get_LastRow()->get_FirstCell()->get_CellFormat();
cellFormat->set_Width(100);
cellFormat->get_Shading()->set_BackgroundPatternColor(System::Drawing::Color::get_Orange());
doc->Save(ArtifactsDir + u"Table.RowCellFormat.docx");

Shows how to modify formatting of a table cell.

auto doc = MakeObject<Document>(MyDir + u"Tables.docx");
auto table = System::DynamicCast<Aspose::Words::Tables::Table>(doc->GetChild(Aspose::Words::NodeType::Table, 0, true));
// Retrieve the first cell in the table
SharedPtr<Cell> firstCell = table->get_FirstRow()->get_FirstCell();
// Modify some row level properties
firstCell->get_CellFormat()->set_Width(30);
// in points
firstCell->get_CellFormat()->set_Orientation(Aspose::Words::TextOrientation::Downward);
firstCell->get_CellFormat()->get_Shading()->set_ForegroundPatternColor(System::Drawing::Color::get_LightGreen());
doc->Save(ArtifactsDir + u"Table.CellFormat.docx");

Shows how to combine the rows from two tables into one.

// Load the document
auto doc = MakeObject<Document>(MyDir + u"Tables.docx");
// Get the first and second table in the document
// The rows from the second table will be appended to the end of the first table
auto firstTable = System::DynamicCast<Aspose::Words::Tables::Table>(doc->GetChild(Aspose::Words::NodeType::Table, 0, true));
auto secondTable = System::DynamicCast<Aspose::Words::Tables::Table>(doc->GetChild(Aspose::Words::NodeType::Table, 1, true));
// Append all rows from the current table to the next
// Due to the design of tables even tables with different cell count and widths can be joined into one table
while (secondTable->get_HasChildNodes())
{
firstTable->get_Rows()->Add(secondTable->get_FirstRow());
}
// Remove the empty table container
secondTable->Remove();
doc->Save(ArtifactsDir + u"Table.CombineTables.docx");

◆ get_FirstParagraph()

System::SharedPtr<Aspose::Words::Paragraph> Aspose::Words::Tables::Cell::get_FirstParagraph ( )

Gets the first paragraph among the immediate children.

Examples

Shows how to insert a nested table using DocumentBuilder.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Build the outer table
SharedPtr<Cell> cell = builder->InsertCell();
builder->Writeln(u"Outer Table Cell 1");
builder->InsertCell();
builder->Writeln(u"Outer Table Cell 2");
// This call is important in order to create a nested table within the first table
// Without this call the cells inserted below will be appended to the outer table
builder->EndTable();
// Move to the first cell of the outer table
builder->MoveTo(cell->get_FirstParagraph());
// Build the inner table
builder->InsertCell();
builder->Writeln(u"Inner Table Cell 1");
builder->InsertCell();
builder->Writeln(u"Inner Table Cell 2");
builder->EndTable();
doc->Save(ArtifactsDir + u"DocumentBuilder.InsertNestedTable.docx");

◆ get_IsFirstCell()

bool Aspose::Words::Tables::Cell::get_IsFirstCell ( )

True if this is the first cell inside a row; false otherwise.

◆ get_IsLastCell()

bool Aspose::Words::Tables::Cell::get_IsLastCell ( )

True if this is the last cell inside a row; false otherwise.

◆ get_LastParagraph()

System::SharedPtr<Aspose::Words::Paragraph> Aspose::Words::Tables::Cell::get_LastParagraph ( )

Gets the last paragraph among the immediate children.

Examples

Shows the difference between the Horizontal and Vertical properties of BorderCollection.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// A BorderCollection is one of a Paragraph's formatting properties
SharedPtr<Paragraph> paragraph = doc->get_FirstSection()->get_Body()->get_FirstParagraph();
SharedPtr<BorderCollection> paragraphBorders = paragraph->get_ParagraphFormat()->get_Borders();
// paragraphBorders belongs to the first paragraph, but these changes will apply to subsequently created paragraphs
paragraphBorders->get_Horizontal()->set_Color(System::Drawing::Color::get_Red());
paragraphBorders->get_Horizontal()->set_LineStyle(Aspose::Words::LineStyle::DashSmallGap);
paragraphBorders->get_Horizontal()->set_LineWidth(3);
// Horizontal borders only appear under a paragraph if there's another paragraph under it
// Right now the first paragraph has no borders
builder->get_CurrentParagraph()->AppendChild(MakeObject<Run>(doc, u"Paragraph above horizontal border."));
// Now the first paragraph will have a red dashed line border under it
// This new second paragraph can have a border too, but only if we add another paragraph underneath it
builder->InsertParagraph();
builder->get_CurrentParagraph()->AppendChild(MakeObject<Run>(doc, u"Paragraph below horizontal border."));
// A table makes use of both vertical and horizontal properties of BorderCollection
// Both these properties can only affect the inner borders of a table
auto table = MakeObject<Table>(doc);
doc->get_FirstSection()->get_Body()->AppendChild(table);
for (int i = 0; i < 3; i++)
{
auto row = MakeObject<Row>(doc);
SharedPtr<BorderCollection> rowBorders = row->get_RowFormat()->get_Borders();
// Vertical borders are ones between rows in a table
rowBorders->get_Horizontal()->set_Color(System::Drawing::Color::get_Red());
rowBorders->get_Horizontal()->set_LineStyle(Aspose::Words::LineStyle::Dot);
rowBorders->get_Horizontal()->set_LineWidth(2.0);
// Vertical borders are ones between cells in a table
rowBorders->get_Vertical()->set_Color(System::Drawing::Color::get_Blue());
rowBorders->get_Vertical()->set_LineStyle(Aspose::Words::LineStyle::Dot);
rowBorders->get_Vertical()->set_LineWidth(2.0);
// A blue dotted vertical border will appear between cells
// A red dotted border will appear between rows
row->AppendChild(MakeObject<Cell>(doc));
row->get_LastCell()->AppendChild(MakeObject<Paragraph>(doc));
row->get_LastCell()->get_FirstParagraph()->AppendChild(MakeObject<Run>(doc, u"Vertical border to the right."));
row->AppendChild(MakeObject<Cell>(doc));
row->get_LastCell()->AppendChild(MakeObject<Paragraph>(doc));
row->get_LastCell()->get_LastParagraph()->AppendChild(MakeObject<Run>(doc, u"Vertical border to the left."));
table->AppendChild(row);
}
doc->Save(ArtifactsDir + u"Border.VerticalAndHorizontalBorders.docx");

◆ get_NodeType()

Aspose::Words::NodeType Aspose::Words::Tables::Cell::get_NodeType ( ) const
overridevirtual

Returns NodeType.Cell.

Implements Aspose::Words::Node.

◆ get_Paragraphs()

System::SharedPtr<Aspose::Words::ParagraphCollection> Aspose::Words::Tables::Cell::get_Paragraphs ( )

Gets a collection of paragraphs that are immediate children of the cell.

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");
auto table = System::DynamicCast<Aspose::Words::Tables::Table>(doc->GetChild(Aspose::Words::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
for (auto cell : System::IterateOver(table->GetChildNodes(Aspose::Words::NodeType::Cell, true)->LINQ_OfType<SharedPtr<Cell> >()))
{
for (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");

◆ get_ParentRow()

System::SharedPtr<Aspose::Words::Tables::Row> Aspose::Words::Tables::Cell::get_ParentRow ( )

Returns the parent row of the cell.

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");
auto table = System::DynamicCast<Aspose::Words::Tables::Table>(doc->GetChild(Aspose::Words::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
for (auto cell : System::IterateOver(table->GetChildNodes(Aspose::Words::NodeType::Cell, true)->LINQ_OfType<SharedPtr<Cell> >()))
{
for (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");

◆ get_Tables()

System::SharedPtr<Aspose::Words::Tables::TableCollection> Aspose::Words::Tables::Cell::get_Tables ( )

Gets a collection of tables that are immediate children of the cell.

◆ GetType()

virtual const System::TypeInfo& Aspose::Words::Tables::Cell::GetType ( ) const
overridevirtual

Reimplemented from Aspose::Words::CompositeNode.

◆ Is()

virtual bool Aspose::Words::Tables::Cell::Is ( const System::TypeInfo target) const
overridevirtual

Reimplemented from Aspose::Words::CompositeNode.

◆ Type()

static const System::TypeInfo& Aspose::Words::Tables::Cell::Type ( )
static
String
@ Bottom
Specifies the bottom border of a paragraph or a table cell.
@ Downward
Text is rotated 90 degrees to the right to appear from top to bottom (tb-rl).
@ Text
Saves the document in the plain text format.
static ASPOSECPP_SHARED_API void WriteLine()
std::enable_if_t<!Details::IsIterable< Enumerable >::value, Details::EnumeratorAdapter< Enumerable, T > > IterateOver(System::SmartPtr< Enumerable > enumerable)
static ASPOSECPP_SHARED_API Color get_Orange()
static ASPOSECPP_SHARED_API Color get_LightGreen()
@ DashSmallGap
static ASPOSECPP_SHARED_API Color get_Blue()
static ASPOSECPP_SHARED_API Color get_Red()
@ Dot
@ Table
A Table object that represents a table in a Word document. A Table node can have Row nodes.
@ Any
Indicates all node types. Allows to select all children.
@ Cell
A cell of a table row. A Cell node can have Paragraph and Table nodes.