Aspose::Words::Tables::CellFormat Class Reference

Detailed Description

Represents all formatting for a table cell.

Examples

Shows how to build a table with custom borders.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
builder->StartTable();
// Setting table formatting options for a document builder
// will apply them to every row and cell that we add with it.
builder->get_ParagraphFormat()->set_Alignment(ParagraphAlignment::Center);
builder->get_CellFormat()->ClearFormatting();
builder->get_CellFormat()->set_Width(150);
builder->get_CellFormat()->set_VerticalAlignment(CellVerticalAlignment::Center);
builder->get_CellFormat()->get_Shading()->set_BackgroundPatternColor(System::Drawing::Color::get_GreenYellow());
builder->get_CellFormat()->set_WrapText(false);
builder->get_CellFormat()->set_FitText(true);
builder->get_RowFormat()->ClearFormatting();
builder->get_RowFormat()->set_HeightRule(HeightRule::Exactly);
builder->get_RowFormat()->set_Height(50);
builder->get_RowFormat()->get_Borders()->set_LineStyle(LineStyle::Engrave3D);
builder->get_RowFormat()->get_Borders()->set_Color(System::Drawing::Color::get_Orange());
builder->InsertCell();
builder->Write(u"Row 1, Col 1");
builder->InsertCell();
builder->Write(u"Row 1, Col 2");
builder->EndRow();
// Changing the formatting will apply it to the current cell,
// and any new cells that we create with the builder afterward.
// This will not affect the cells that we have added previously.
builder->get_CellFormat()->get_Shading()->ClearFormatting();
builder->InsertCell();
builder->Write(u"Row 2, Col 1");
builder->InsertCell();
builder->Write(u"Row 2, Col 2");
builder->EndRow();
// Increase row height to fit the vertical text.
builder->InsertCell();
builder->get_RowFormat()->set_Height(150);
builder->get_CellFormat()->set_Orientation(TextOrientation::Upward);
builder->Write(u"Row 3, Col 1");
builder->InsertCell();
builder->get_CellFormat()->set_Orientation(TextOrientation::Downward);
builder->Write(u"Row 3, Col 2");
builder->EndRow();
builder->EndTable();
doc->Save(ArtifactsDir + u"DocumentBuilder.InsertTable.docx");

Shows how to modify the format of rows and cells in a table.

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();
// Use the first row's "RowFormat" property to modify the formatting
// of the contents of all cells in this row.
SharedPtr<RowFormat> rowFormat = table->get_FirstRow()->get_RowFormat();
rowFormat->set_Height(25);
rowFormat->get_Borders()->idx_get(BorderType::Bottom)->set_Color(System::Drawing::Color::get_Red());
// Use the "CellFormat" property of the first cell in the last row to modify the formatting of that cell's contents.
SharedPtr<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");
SharedPtr<Table> table = doc->get_FirstSection()->get_Body()->get_Tables()->idx_get(0);
SharedPtr<Cell> firstCell = table->get_FirstRow()->get_FirstCell();
// Use a cell's "CellFormat" property to set formatting that modifies the appearance of that cell.
firstCell->get_CellFormat()->set_Width(30);
firstCell->get_CellFormat()->set_Orientation(TextOrientation::Downward);
firstCell->get_CellFormat()->get_Shading()->set_ForegroundPatternColor(System::Drawing::Color::get_LightGreen());
doc->Save(ArtifactsDir + u"Table.CellFormat.docx");

#include <Aspose.Words.Cpp/Tables/CellFormat.h>

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

Public Member Functions

void ClearFormatting ()
 Resets to default cell formatting. Does not change the width of the cell. More...
 
SharedPtr< BorderCollectionget_Borders ()
 Gets collection of borders of the cell. More...
 
double get_BottomPadding ()
 Returns or sets the amount of space (in points) to add below the contents of cell. More...
 
bool get_FitText ()
 If true, fits text in the cell, compressing each paragraph to the width of the cell. More...
 
CellMerge get_HorizontalMerge ()
 Specifies how the cell is merged horizontally with other cells in the row. More...
 
double get_LeftPadding ()
 Returns or sets the amount of space (in points) to add to the left of the contents of cell. More...
 
TextOrientation get_Orientation ()
 Returns or sets the orientation of text in a table cell. More...
 
SharedPtr< PreferredWidthget_PreferredWidth ()
 Returns or sets the preferred width of the cell. More...
 
double get_RightPadding ()
 Returns or sets the amount of space (in points) to add to the right of the contents of cell. More...
 
SharedPtr< Shadingget_Shading ()
 Returns a Shading object that refers to the shading formatting for the cell. More...
 
double get_TopPadding ()
 Returns or sets the amount of space (in points) to add above the contents of cell. More...
 
CellVerticalAlignment get_VerticalAlignment ()
 Returns or sets the vertical alignment of text in the cell. More...
 
CellMerge get_VerticalMerge ()
 Specifies how the cell is merged with other cells vertically. More...
 
double get_Width ()
 Gets the width of the cell in points. More...
 
bool get_WrapText ()
 If true, wrap text for the cell. More...
 
virtual const TypeInfoGetType () const override
 
virtual bool Is (const TypeInfo &target) const override
 
void set_BottomPadding (double value)
 Setter for get_BottomPadding. More...
 
void set_FitText (bool value)
 Setter for get_FitText. More...
 
void set_HorizontalMerge (CellMerge value)
 Setter for get_HorizontalMerge. More...
 
void set_LeftPadding (double value)
 Setter for get_LeftPadding. More...
 
void set_Orientation (TextOrientation value)
 Setter for get_Orientation. More...
 
void set_PreferredWidth (SharedPtr< PreferredWidth > value)
 Setter for get_PreferredWidth. More...
 
void set_RightPadding (double value)
 Setter for get_RightPadding. More...
 
void set_TopPadding (double value)
 Setter for get_TopPadding. More...
 
void set_VerticalAlignment (CellVerticalAlignment value)
 Setter for get_VerticalAlignment. More...
 
void set_VerticalMerge (CellMerge value)
 Setter for get_VerticalMerge. More...
 
void set_Width (double value)
 Setter for get_Width. More...
 
void set_WrapText (bool value)
 Setter for get_WrapText. More...
 
void SetPaddings (double leftPadding, double topPadding, double rightPadding, double bottomPadding)
 Sets the amount of space (in points) to add to the left/top/right/bottom of the contents of cell. More...
 

Static Public Member Functions

static const TypeInfoType ()
 

Member Function Documentation

◆ ClearFormatting()

void Aspose::Words::Tables::CellFormat::ClearFormatting ( )

Resets to default cell formatting. Does not change the width of the cell.

Examples

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

auto doc = MakeObject<Document>(MyDir + u"Tables.docx");
// Below are two ways of getting a table from a document.
// 1 - From the "Tables" collection of a Body node:
SharedPtr<Table> firstTable = doc->get_FirstSection()->get_Body()->get_Tables()->idx_get(0);
// 2 - Using the "GetChild" method:
auto secondTable = System::DynamicCast<Table>(doc->GetChild(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(ArtifactsDir + u"Table.CombineTables.docx");

◆ get_Borders()

System::SharedPtr<Aspose::Words::BorderCollection> Aspose::Words::Tables::CellFormat::get_Borders ( )

Gets collection of borders of the cell.

Examples

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

auto doc = MakeObject<Document>(MyDir + u"Tables.docx");
// Below are two ways of getting a table from a document.
// 1 - From the "Tables" collection of a Body node:
SharedPtr<Table> firstTable = doc->get_FirstSection()->get_Body()->get_Tables()->idx_get(0);
// 2 - Using the "GetChild" method:
auto secondTable = System::DynamicCast<Table>(doc->GetChild(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(ArtifactsDir + u"Table.CombineTables.docx");

◆ get_BottomPadding()

double Aspose::Words::Tables::CellFormat::get_BottomPadding ( )

Returns or sets the amount of space (in points) to add below the contents of cell.

Examples

Shows how to format cells with a document builder.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
SharedPtr<Table> table = builder->StartTable();
builder->InsertCell();
builder->Write(u"Row 1, cell 1.");
// Insert a second cell, and then configure cell text padding options.
// The builder will apply these settings at its current cell, and any new cells creates afterwards.
builder->InsertCell();
SharedPtr<CellFormat> cellFormat = builder->get_CellFormat();
cellFormat->set_Width(250);
cellFormat->set_LeftPadding(30);
cellFormat->set_RightPadding(30);
cellFormat->set_TopPadding(30);
cellFormat->set_BottomPadding(30);
builder->Write(u"Row 1, cell 2.");
builder->EndRow();
builder->EndTable();
// The first cell was unaffected by the padding reconfiguration, and still holds the default values.
ASPOSE_ASSERT_EQ(0.0, table->get_FirstRow()->get_Cells()->idx_get(0)->get_CellFormat()->get_Width());
ASPOSE_ASSERT_EQ(5.4, table->get_FirstRow()->get_Cells()->idx_get(0)->get_CellFormat()->get_LeftPadding());
ASPOSE_ASSERT_EQ(5.4, table->get_FirstRow()->get_Cells()->idx_get(0)->get_CellFormat()->get_RightPadding());
ASPOSE_ASSERT_EQ(0.0, table->get_FirstRow()->get_Cells()->idx_get(0)->get_CellFormat()->get_TopPadding());
ASPOSE_ASSERT_EQ(0.0, table->get_FirstRow()->get_Cells()->idx_get(0)->get_CellFormat()->get_BottomPadding());
ASPOSE_ASSERT_EQ(250.0, table->get_FirstRow()->get_Cells()->idx_get(1)->get_CellFormat()->get_Width());
ASPOSE_ASSERT_EQ(30.0, table->get_FirstRow()->get_Cells()->idx_get(1)->get_CellFormat()->get_LeftPadding());
ASPOSE_ASSERT_EQ(30.0, table->get_FirstRow()->get_Cells()->idx_get(1)->get_CellFormat()->get_RightPadding());
ASPOSE_ASSERT_EQ(30.0, table->get_FirstRow()->get_Cells()->idx_get(1)->get_CellFormat()->get_TopPadding());
ASPOSE_ASSERT_EQ(30.0, table->get_FirstRow()->get_Cells()->idx_get(1)->get_CellFormat()->get_BottomPadding());
// The first cell will still grow in the output document to match the size of its neighboring cell.
doc->Save(ArtifactsDir + u"DocumentBuilder.SetCellFormatting.docx");

◆ get_FitText()

bool Aspose::Words::Tables::CellFormat::get_FitText ( )

If true, fits text in the cell, compressing each paragraph to the width of the cell.

Examples

Shows how to build a table with custom borders.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
builder->StartTable();
// Setting table formatting options for a document builder
// will apply them to every row and cell that we add with it.
builder->get_ParagraphFormat()->set_Alignment(ParagraphAlignment::Center);
builder->get_CellFormat()->ClearFormatting();
builder->get_CellFormat()->set_Width(150);
builder->get_CellFormat()->set_VerticalAlignment(CellVerticalAlignment::Center);
builder->get_CellFormat()->get_Shading()->set_BackgroundPatternColor(System::Drawing::Color::get_GreenYellow());
builder->get_CellFormat()->set_WrapText(false);
builder->get_CellFormat()->set_FitText(true);
builder->get_RowFormat()->ClearFormatting();
builder->get_RowFormat()->set_HeightRule(HeightRule::Exactly);
builder->get_RowFormat()->set_Height(50);
builder->get_RowFormat()->get_Borders()->set_LineStyle(LineStyle::Engrave3D);
builder->get_RowFormat()->get_Borders()->set_Color(System::Drawing::Color::get_Orange());
builder->InsertCell();
builder->Write(u"Row 1, Col 1");
builder->InsertCell();
builder->Write(u"Row 1, Col 2");
builder->EndRow();
// Changing the formatting will apply it to the current cell,
// and any new cells that we create with the builder afterward.
// This will not affect the cells that we have added previously.
builder->get_CellFormat()->get_Shading()->ClearFormatting();
builder->InsertCell();
builder->Write(u"Row 2, Col 1");
builder->InsertCell();
builder->Write(u"Row 2, Col 2");
builder->EndRow();
// Increase row height to fit the vertical text.
builder->InsertCell();
builder->get_RowFormat()->set_Height(150);
builder->get_CellFormat()->set_Orientation(TextOrientation::Upward);
builder->Write(u"Row 3, Col 1");
builder->InsertCell();
builder->get_CellFormat()->set_Orientation(TextOrientation::Downward);
builder->Write(u"Row 3, Col 2");
builder->EndRow();
builder->EndTable();
doc->Save(ArtifactsDir + u"DocumentBuilder.InsertTable.docx");

◆ get_HorizontalMerge()

Aspose::Words::Tables::CellMerge Aspose::Words::Tables::CellFormat::get_HorizontalMerge ( )

Specifies how the cell is merged horizontally with other cells in the row.

See also
Aspose::Words::Tables::CellFormat::get_VerticalMerge
Examples

Shows how to merge table cells horizontally.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Insert a cell into the first column of the first row.
// This cell will be the first in a range of horizontally merged cells.
builder->InsertCell();
builder->get_CellFormat()->set_HorizontalMerge(CellMerge::First);
builder->Write(u"Text in merged cells.");
// Insert a cell into the second column of the first row. Instead of adding text contents,
// we will merge this cell with the first cell that we added directly to the left.
builder->InsertCell();
builder->get_CellFormat()->set_HorizontalMerge(CellMerge::Previous);
builder->EndRow();
// Insert two more unmerged cells to the second row.
builder->get_CellFormat()->set_HorizontalMerge(CellMerge::None);
builder->InsertCell();
builder->Write(u"Text in unmerged cell.");
builder->InsertCell();
builder->Write(u"Text in unmerged cell.");
builder->EndRow();
builder->EndTable();
doc->Save(ArtifactsDir + u"CellFormat.HorizontalMerge.docx");

Prints the horizontal and vertical merge type of a cell.

void CheckCellsMerged()
{
auto doc = MakeObject<Document>(MyDir + u"Table with merged cells.docx");
SharedPtr<Table> table = doc->get_FirstSection()->get_Body()->get_Tables()->idx_get(0);
for (const auto& row : System::IterateOver(table->get_Rows()->LINQ_OfType<SharedPtr<Row>>()))
{
for (const auto& cell : System::IterateOver(row->get_Cells()->LINQ_OfType<SharedPtr<Cell>>()))
{
std::cout << PrintCellMergeType(cell) << std::endl;
}
}
}
String PrintCellMergeType(SharedPtr<Cell> cell)
{
bool isHorizontallyMerged = cell->get_CellFormat()->get_HorizontalMerge() != CellMerge::None;
bool isVerticallyMerged = cell->get_CellFormat()->get_VerticalMerge() != CellMerge::None;
String cellLocation = String::Format(u"R{0}, C{1}", cell->get_ParentRow()->get_ParentTable()->IndexOf(cell->get_ParentRow()) + 1,
cell->get_ParentRow()->IndexOf(cell) + 1);
if (isHorizontallyMerged && isVerticallyMerged)
{
return String::Format(u"The cell at {0} is both horizontally and vertically merged", cellLocation);
}
if (isHorizontallyMerged)
{
return String::Format(u"The cell at {0} is horizontally merged.", cellLocation);
}
return isVerticallyMerged ? String::Format(u"The cell at {0} is vertically merged", cellLocation)
: String::Format(u"The cell at {0} is not merged", cellLocation);
}

◆ get_LeftPadding()

double Aspose::Words::Tables::CellFormat::get_LeftPadding ( )

Returns or sets the amount of space (in points) to add to the left of the contents of cell.

Examples

Shows how to format cells with a document builder.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
SharedPtr<Table> table = builder->StartTable();
builder->InsertCell();
builder->Write(u"Row 1, cell 1.");
// Insert a second cell, and then configure cell text padding options.
// The builder will apply these settings at its current cell, and any new cells creates afterwards.
builder->InsertCell();
SharedPtr<CellFormat> cellFormat = builder->get_CellFormat();
cellFormat->set_Width(250);
cellFormat->set_LeftPadding(30);
cellFormat->set_RightPadding(30);
cellFormat->set_TopPadding(30);
cellFormat->set_BottomPadding(30);
builder->Write(u"Row 1, cell 2.");
builder->EndRow();
builder->EndTable();
// The first cell was unaffected by the padding reconfiguration, and still holds the default values.
ASPOSE_ASSERT_EQ(0.0, table->get_FirstRow()->get_Cells()->idx_get(0)->get_CellFormat()->get_Width());
ASPOSE_ASSERT_EQ(5.4, table->get_FirstRow()->get_Cells()->idx_get(0)->get_CellFormat()->get_LeftPadding());
ASPOSE_ASSERT_EQ(5.4, table->get_FirstRow()->get_Cells()->idx_get(0)->get_CellFormat()->get_RightPadding());
ASPOSE_ASSERT_EQ(0.0, table->get_FirstRow()->get_Cells()->idx_get(0)->get_CellFormat()->get_TopPadding());
ASPOSE_ASSERT_EQ(0.0, table->get_FirstRow()->get_Cells()->idx_get(0)->get_CellFormat()->get_BottomPadding());
ASPOSE_ASSERT_EQ(250.0, table->get_FirstRow()->get_Cells()->idx_get(1)->get_CellFormat()->get_Width());
ASPOSE_ASSERT_EQ(30.0, table->get_FirstRow()->get_Cells()->idx_get(1)->get_CellFormat()->get_LeftPadding());
ASPOSE_ASSERT_EQ(30.0, table->get_FirstRow()->get_Cells()->idx_get(1)->get_CellFormat()->get_RightPadding());
ASPOSE_ASSERT_EQ(30.0, table->get_FirstRow()->get_Cells()->idx_get(1)->get_CellFormat()->get_TopPadding());
ASPOSE_ASSERT_EQ(30.0, table->get_FirstRow()->get_Cells()->idx_get(1)->get_CellFormat()->get_BottomPadding());
// The first cell will still grow in the output document to match the size of its neighboring cell.
doc->Save(ArtifactsDir + u"DocumentBuilder.SetCellFormatting.docx");

◆ get_Orientation()

Aspose::Words::TextOrientation Aspose::Words::Tables::CellFormat::get_Orientation ( )

Returns or sets the orientation of text in a table cell.

Examples

Shows how to build a table with custom borders.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
builder->StartTable();
// Setting table formatting options for a document builder
// will apply them to every row and cell that we add with it.
builder->get_ParagraphFormat()->set_Alignment(ParagraphAlignment::Center);
builder->get_CellFormat()->ClearFormatting();
builder->get_CellFormat()->set_Width(150);
builder->get_CellFormat()->set_VerticalAlignment(CellVerticalAlignment::Center);
builder->get_CellFormat()->get_Shading()->set_BackgroundPatternColor(System::Drawing::Color::get_GreenYellow());
builder->get_CellFormat()->set_WrapText(false);
builder->get_CellFormat()->set_FitText(true);
builder->get_RowFormat()->ClearFormatting();
builder->get_RowFormat()->set_HeightRule(HeightRule::Exactly);
builder->get_RowFormat()->set_Height(50);
builder->get_RowFormat()->get_Borders()->set_LineStyle(LineStyle::Engrave3D);
builder->get_RowFormat()->get_Borders()->set_Color(System::Drawing::Color::get_Orange());
builder->InsertCell();
builder->Write(u"Row 1, Col 1");
builder->InsertCell();
builder->Write(u"Row 1, Col 2");
builder->EndRow();
// Changing the formatting will apply it to the current cell,
// and any new cells that we create with the builder afterward.
// This will not affect the cells that we have added previously.
builder->get_CellFormat()->get_Shading()->ClearFormatting();
builder->InsertCell();
builder->Write(u"Row 2, Col 1");
builder->InsertCell();
builder->Write(u"Row 2, Col 2");
builder->EndRow();
// Increase row height to fit the vertical text.
builder->InsertCell();
builder->get_RowFormat()->set_Height(150);
builder->get_CellFormat()->set_Orientation(TextOrientation::Upward);
builder->Write(u"Row 3, Col 1");
builder->InsertCell();
builder->get_CellFormat()->set_Orientation(TextOrientation::Downward);
builder->Write(u"Row 3, Col 2");
builder->EndRow();
builder->EndTable();
doc->Save(ArtifactsDir + u"DocumentBuilder.InsertTable.docx");

Shows how to build a formatted 2x2 table.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
SharedPtr<Table> table = builder->StartTable();
builder->InsertCell();
builder->get_CellFormat()->set_VerticalAlignment(CellVerticalAlignment::Center);
builder->Write(u"Row 1, cell 1.");
builder->InsertCell();
builder->Write(u"Row 1, cell 2.");
builder->EndRow();
// While building the table, the document builder will apply its current RowFormat/CellFormat property values
// to the current row/cell that its cursor is in and any new rows/cells as it creates them.
ASSERT_EQ(CellVerticalAlignment::Center, table->get_Rows()->idx_get(0)->get_Cells()->idx_get(0)->get_CellFormat()->get_VerticalAlignment());
ASSERT_EQ(CellVerticalAlignment::Center, table->get_Rows()->idx_get(0)->get_Cells()->idx_get(1)->get_CellFormat()->get_VerticalAlignment());
builder->InsertCell();
builder->get_RowFormat()->set_Height(100);
builder->get_RowFormat()->set_HeightRule(HeightRule::Exactly);
builder->get_CellFormat()->set_Orientation(TextOrientation::Upward);
builder->Write(u"Row 2, cell 1.");
builder->InsertCell();
builder->get_CellFormat()->set_Orientation(TextOrientation::Downward);
builder->Write(u"Row 2, cell 2.");
builder->EndRow();
builder->EndTable();
// Previously added rows and cells are not retroactively affected by changes to the builder's formatting.
ASPOSE_ASSERT_EQ(0, table->get_Rows()->idx_get(0)->get_RowFormat()->get_Height());
ASSERT_EQ(HeightRule::Auto, table->get_Rows()->idx_get(0)->get_RowFormat()->get_HeightRule());
ASPOSE_ASSERT_EQ(100, table->get_Rows()->idx_get(1)->get_RowFormat()->get_Height());
ASSERT_EQ(HeightRule::Exactly, table->get_Rows()->idx_get(1)->get_RowFormat()->get_HeightRule());
ASSERT_EQ(TextOrientation::Upward, table->get_Rows()->idx_get(1)->get_Cells()->idx_get(0)->get_CellFormat()->get_Orientation());
ASSERT_EQ(TextOrientation::Downward, table->get_Rows()->idx_get(1)->get_Cells()->idx_get(1)->get_CellFormat()->get_Orientation());
doc->Save(ArtifactsDir + u"DocumentBuilder.BuildTable.docx");

◆ get_PreferredWidth()

System::SharedPtr<Aspose::Words::Tables::PreferredWidth> Aspose::Words::Tables::CellFormat::get_PreferredWidth ( )

Returns or sets the preferred width of the cell.

The preferred width (along with the table's Auto Fit option) determines how the actual width of the cell is calculated by the table layout algorithm. Table layout can be performed by Aspose.Words when it saves the document or by Microsoft Word when it displays the document.

The preferred width can be specified in points or in percent. The preferred width can also be specified as "auto", which means no preferred width is specified.

The default value is Auto.

See also
Aspose::Words::Tables::CellFormat::get_Width
Examples

Shows how to set a preferred width for table cells.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
SharedPtr<Table> table = builder->StartTable();
// There are two ways of applying the "PreferredWidth" class to table cells.
// 1 - Set an absolute preferred width based on points:
builder->InsertCell();
builder->get_CellFormat()->set_PreferredWidth(PreferredWidth::FromPoints(40));
builder->get_CellFormat()->get_Shading()->set_BackgroundPatternColor(System::Drawing::Color::get_LightYellow());
builder->Writeln(String::Format(u"Cell with a width of {0}.", builder->get_CellFormat()->get_PreferredWidth()));
// 2 - Set a relative preferred width based on percent of the table's width:
builder->InsertCell();
builder->get_CellFormat()->set_PreferredWidth(PreferredWidth::FromPercent(20));
builder->get_CellFormat()->get_Shading()->set_BackgroundPatternColor(System::Drawing::Color::get_LightBlue());
builder->Writeln(String::Format(u"Cell with a width of {0}.", builder->get_CellFormat()->get_PreferredWidth()));
builder->InsertCell();
// A cell with no preferred width specified will take up the rest of the available space.
builder->get_CellFormat()->set_PreferredWidth(PreferredWidth::Auto());
// Each configuration of the "PreferredWidth" property creates a new object.
ASSERT_NE(System::ObjectExt::GetHashCode(table->get_FirstRow()->get_Cells()->idx_get(1)->get_CellFormat()->get_PreferredWidth()),
System::ObjectExt::GetHashCode(builder->get_CellFormat()->get_PreferredWidth()));
builder->get_CellFormat()->get_Shading()->set_BackgroundPatternColor(System::Drawing::Color::get_LightGreen());
builder->Writeln(u"Automatically sized cell.");
doc->Save(ArtifactsDir + u"DocumentBuilder.InsertCellsWithPreferredWidths.docx");

◆ get_RightPadding()

double Aspose::Words::Tables::CellFormat::get_RightPadding ( )

Returns or sets the amount of space (in points) to add to the right of the contents of cell.

Examples

Shows how to format cells with a document builder.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
SharedPtr<Table> table = builder->StartTable();
builder->InsertCell();
builder->Write(u"Row 1, cell 1.");
// Insert a second cell, and then configure cell text padding options.
// The builder will apply these settings at its current cell, and any new cells creates afterwards.
builder->InsertCell();
SharedPtr<CellFormat> cellFormat = builder->get_CellFormat();
cellFormat->set_Width(250);
cellFormat->set_LeftPadding(30);
cellFormat->set_RightPadding(30);
cellFormat->set_TopPadding(30);
cellFormat->set_BottomPadding(30);
builder->Write(u"Row 1, cell 2.");
builder->EndRow();
builder->EndTable();
// The first cell was unaffected by the padding reconfiguration, and still holds the default values.
ASPOSE_ASSERT_EQ(0.0, table->get_FirstRow()->get_Cells()->idx_get(0)->get_CellFormat()->get_Width());
ASPOSE_ASSERT_EQ(5.4, table->get_FirstRow()->get_Cells()->idx_get(0)->get_CellFormat()->get_LeftPadding());
ASPOSE_ASSERT_EQ(5.4, table->get_FirstRow()->get_Cells()->idx_get(0)->get_CellFormat()->get_RightPadding());
ASPOSE_ASSERT_EQ(0.0, table->get_FirstRow()->get_Cells()->idx_get(0)->get_CellFormat()->get_TopPadding());
ASPOSE_ASSERT_EQ(0.0, table->get_FirstRow()->get_Cells()->idx_get(0)->get_CellFormat()->get_BottomPadding());
ASPOSE_ASSERT_EQ(250.0, table->get_FirstRow()->get_Cells()->idx_get(1)->get_CellFormat()->get_Width());
ASPOSE_ASSERT_EQ(30.0, table->get_FirstRow()->get_Cells()->idx_get(1)->get_CellFormat()->get_LeftPadding());
ASPOSE_ASSERT_EQ(30.0, table->get_FirstRow()->get_Cells()->idx_get(1)->get_CellFormat()->get_RightPadding());
ASPOSE_ASSERT_EQ(30.0, table->get_FirstRow()->get_Cells()->idx_get(1)->get_CellFormat()->get_TopPadding());
ASPOSE_ASSERT_EQ(30.0, table->get_FirstRow()->get_Cells()->idx_get(1)->get_CellFormat()->get_BottomPadding());
// The first cell will still grow in the output document to match the size of its neighboring cell.
doc->Save(ArtifactsDir + u"DocumentBuilder.SetCellFormatting.docx");

◆ get_Shading()

System::SharedPtr<Aspose::Words::Shading> Aspose::Words::Tables::CellFormat::get_Shading ( )

Returns a Shading object that refers to the shading formatting for the cell.

Examples

Shows how to build a table with custom borders.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
builder->StartTable();
// Setting table formatting options for a document builder
// will apply them to every row and cell that we add with it.
builder->get_ParagraphFormat()->set_Alignment(ParagraphAlignment::Center);
builder->get_CellFormat()->ClearFormatting();
builder->get_CellFormat()->set_Width(150);
builder->get_CellFormat()->set_VerticalAlignment(CellVerticalAlignment::Center);
builder->get_CellFormat()->get_Shading()->set_BackgroundPatternColor(System::Drawing::Color::get_GreenYellow());
builder->get_CellFormat()->set_WrapText(false);
builder->get_CellFormat()->set_FitText(true);
builder->get_RowFormat()->ClearFormatting();
builder->get_RowFormat()->set_HeightRule(HeightRule::Exactly);
builder->get_RowFormat()->set_Height(50);
builder->get_RowFormat()->get_Borders()->set_LineStyle(LineStyle::Engrave3D);
builder->get_RowFormat()->get_Borders()->set_Color(System::Drawing::Color::get_Orange());
builder->InsertCell();
builder->Write(u"Row 1, Col 1");
builder->InsertCell();
builder->Write(u"Row 1, Col 2");
builder->EndRow();
// Changing the formatting will apply it to the current cell,
// and any new cells that we create with the builder afterward.
// This will not affect the cells that we have added previously.
builder->get_CellFormat()->get_Shading()->ClearFormatting();
builder->InsertCell();
builder->Write(u"Row 2, Col 1");
builder->InsertCell();
builder->Write(u"Row 2, Col 2");
builder->EndRow();
// Increase row height to fit the vertical text.
builder->InsertCell();
builder->get_RowFormat()->set_Height(150);
builder->get_CellFormat()->set_Orientation(TextOrientation::Upward);
builder->Write(u"Row 3, Col 1");
builder->InsertCell();
builder->get_CellFormat()->set_Orientation(TextOrientation::Downward);
builder->Write(u"Row 3, Col 2");
builder->EndRow();
builder->EndTable();
doc->Save(ArtifactsDir + u"DocumentBuilder.InsertTable.docx");

Shows how to modify the format of rows and cells in a table.

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();
// Use the first row's "RowFormat" property to modify the formatting
// of the contents of all cells in this row.
SharedPtr<RowFormat> rowFormat = table->get_FirstRow()->get_RowFormat();
rowFormat->set_Height(25);
rowFormat->get_Borders()->idx_get(BorderType::Bottom)->set_Color(System::Drawing::Color::get_Red());
// Use the "CellFormat" property of the first cell in the last row to modify the formatting of that cell's contents.
SharedPtr<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");

◆ get_TopPadding()

double Aspose::Words::Tables::CellFormat::get_TopPadding ( )

Returns or sets the amount of space (in points) to add above the contents of cell.

Examples

Shows how to format cells with a document builder.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
SharedPtr<Table> table = builder->StartTable();
builder->InsertCell();
builder->Write(u"Row 1, cell 1.");
// Insert a second cell, and then configure cell text padding options.
// The builder will apply these settings at its current cell, and any new cells creates afterwards.
builder->InsertCell();
SharedPtr<CellFormat> cellFormat = builder->get_CellFormat();
cellFormat->set_Width(250);
cellFormat->set_LeftPadding(30);
cellFormat->set_RightPadding(30);
cellFormat->set_TopPadding(30);
cellFormat->set_BottomPadding(30);
builder->Write(u"Row 1, cell 2.");
builder->EndRow();
builder->EndTable();
// The first cell was unaffected by the padding reconfiguration, and still holds the default values.
ASPOSE_ASSERT_EQ(0.0, table->get_FirstRow()->get_Cells()->idx_get(0)->get_CellFormat()->get_Width());
ASPOSE_ASSERT_EQ(5.4, table->get_FirstRow()->get_Cells()->idx_get(0)->get_CellFormat()->get_LeftPadding());
ASPOSE_ASSERT_EQ(5.4, table->get_FirstRow()->get_Cells()->idx_get(0)->get_CellFormat()->get_RightPadding());
ASPOSE_ASSERT_EQ(0.0, table->get_FirstRow()->get_Cells()->idx_get(0)->get_CellFormat()->get_TopPadding());
ASPOSE_ASSERT_EQ(0.0, table->get_FirstRow()->get_Cells()->idx_get(0)->get_CellFormat()->get_BottomPadding());
ASPOSE_ASSERT_EQ(250.0, table->get_FirstRow()->get_Cells()->idx_get(1)->get_CellFormat()->get_Width());
ASPOSE_ASSERT_EQ(30.0, table->get_FirstRow()->get_Cells()->idx_get(1)->get_CellFormat()->get_LeftPadding());
ASPOSE_ASSERT_EQ(30.0, table->get_FirstRow()->get_Cells()->idx_get(1)->get_CellFormat()->get_RightPadding());
ASPOSE_ASSERT_EQ(30.0, table->get_FirstRow()->get_Cells()->idx_get(1)->get_CellFormat()->get_TopPadding());
ASPOSE_ASSERT_EQ(30.0, table->get_FirstRow()->get_Cells()->idx_get(1)->get_CellFormat()->get_BottomPadding());
// The first cell will still grow in the output document to match the size of its neighboring cell.
doc->Save(ArtifactsDir + u"DocumentBuilder.SetCellFormatting.docx");

◆ get_VerticalAlignment()

Aspose::Words::Tables::CellVerticalAlignment Aspose::Words::Tables::CellFormat::get_VerticalAlignment ( )

Returns or sets the vertical alignment of text in the cell.

Examples

Shows how to build a table with custom borders.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
builder->StartTable();
// Setting table formatting options for a document builder
// will apply them to every row and cell that we add with it.
builder->get_ParagraphFormat()->set_Alignment(ParagraphAlignment::Center);
builder->get_CellFormat()->ClearFormatting();
builder->get_CellFormat()->set_Width(150);
builder->get_CellFormat()->set_VerticalAlignment(CellVerticalAlignment::Center);
builder->get_CellFormat()->get_Shading()->set_BackgroundPatternColor(System::Drawing::Color::get_GreenYellow());
builder->get_CellFormat()->set_WrapText(false);
builder->get_CellFormat()->set_FitText(true);
builder->get_RowFormat()->ClearFormatting();
builder->get_RowFormat()->set_HeightRule(HeightRule::Exactly);
builder->get_RowFormat()->set_Height(50);
builder->get_RowFormat()->get_Borders()->set_LineStyle(LineStyle::Engrave3D);
builder->get_RowFormat()->get_Borders()->set_Color(System::Drawing::Color::get_Orange());
builder->InsertCell();
builder->Write(u"Row 1, Col 1");
builder->InsertCell();
builder->Write(u"Row 1, Col 2");
builder->EndRow();
// Changing the formatting will apply it to the current cell,
// and any new cells that we create with the builder afterward.
// This will not affect the cells that we have added previously.
builder->get_CellFormat()->get_Shading()->ClearFormatting();
builder->InsertCell();
builder->Write(u"Row 2, Col 1");
builder->InsertCell();
builder->Write(u"Row 2, Col 2");
builder->EndRow();
// Increase row height to fit the vertical text.
builder->InsertCell();
builder->get_RowFormat()->set_Height(150);
builder->get_CellFormat()->set_Orientation(TextOrientation::Upward);
builder->Write(u"Row 3, Col 1");
builder->InsertCell();
builder->get_CellFormat()->set_Orientation(TextOrientation::Downward);
builder->Write(u"Row 3, Col 2");
builder->EndRow();
builder->EndTable();
doc->Save(ArtifactsDir + u"DocumentBuilder.InsertTable.docx");

◆ get_VerticalMerge()

Aspose::Words::Tables::CellMerge Aspose::Words::Tables::CellFormat::get_VerticalMerge ( )

Specifies how the cell is merged with other cells vertically.

Cells can only be merged vertically if their left and right boundaries are identical.

When cells are vertically merged, the display areas of the merged cells are consolidated. The consolidated area is used to display the contents of the first vertically merged cell and all other vertically merged cells must be empty.

See also
Aspose::Words::Tables::CellFormat::get_HorizontalMerge
Examples

Shows how to merge table cells vertically.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Insert a cell into the first column of the first row.
// This cell will be the first in a range of vertically merged cells.
builder->InsertCell();
builder->get_CellFormat()->set_VerticalMerge(CellMerge::First);
builder->Write(u"Text in merged cells.");
// Insert a cell into the second column of the first row, then end the row.
// Also, configure the builder to disable vertical merging in created cells.
builder->InsertCell();
builder->get_CellFormat()->set_VerticalMerge(CellMerge::None);
builder->Write(u"Text in unmerged cell.");
builder->EndRow();
// Insert a cell into the first column of the second row.
// Instead of adding text contents, we will merge this cell with the first cell that we added directly above.
builder->InsertCell();
builder->get_CellFormat()->set_VerticalMerge(CellMerge::Previous);
// Insert another independent cell in the second column of the second row.
builder->InsertCell();
builder->get_CellFormat()->set_VerticalMerge(CellMerge::None);
builder->Write(u"Text in unmerged cell.");
builder->EndRow();
builder->EndTable();
doc->Save(ArtifactsDir + u"CellFormat.VerticalMerge.docx");

Prints the horizontal and vertical merge type of a cell.

void CheckCellsMerged()
{
auto doc = MakeObject<Document>(MyDir + u"Table with merged cells.docx");
SharedPtr<Table> table = doc->get_FirstSection()->get_Body()->get_Tables()->idx_get(0);
for (const auto& row : System::IterateOver(table->get_Rows()->LINQ_OfType<SharedPtr<Row>>()))
{
for (const auto& cell : System::IterateOver(row->get_Cells()->LINQ_OfType<SharedPtr<Cell>>()))
{
std::cout << PrintCellMergeType(cell) << std::endl;
}
}
}
String PrintCellMergeType(SharedPtr<Cell> cell)
{
bool isHorizontallyMerged = cell->get_CellFormat()->get_HorizontalMerge() != CellMerge::None;
bool isVerticallyMerged = cell->get_CellFormat()->get_VerticalMerge() != CellMerge::None;
String cellLocation = String::Format(u"R{0}, C{1}", cell->get_ParentRow()->get_ParentTable()->IndexOf(cell->get_ParentRow()) + 1,
cell->get_ParentRow()->IndexOf(cell) + 1);
if (isHorizontallyMerged && isVerticallyMerged)
{
return String::Format(u"The cell at {0} is both horizontally and vertically merged", cellLocation);
}
if (isHorizontallyMerged)
{
return String::Format(u"The cell at {0} is horizontally merged.", cellLocation);
}
return isVerticallyMerged ? String::Format(u"The cell at {0} is vertically merged", cellLocation)
: String::Format(u"The cell at {0} is not merged", cellLocation);
}

◆ get_Width()

double Aspose::Words::Tables::CellFormat::get_Width ( )

Gets the width of the cell in points.

The width is calculated by Aspose.Words on document loading and saving. Currently, not every combination of table, cell and document properties is supported. The returned value may not be accurate for some documents. It may not exactly match the cell width as calculated by MS Word when the document is opened in MS Word.

Setting this property is not recommended. There is no guarantee that the cell will actually have the set width. The width may be adjusted to accommodate cell contents in an auto-fit table layout. Cells in other rows may have conflicting width settings. The table may be resized to fit into the container or to meet table width settings. Consider using PreferredWidth for setting the cell width. Setting this property sets PreferredWidth implicitly since version 15.8.

See also
Aspose::Words::Tables::CellFormat::get_PreferredWidth
Examples

Shows how to build a table with custom borders.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
builder->StartTable();
// Setting table formatting options for a document builder
// will apply them to every row and cell that we add with it.
builder->get_ParagraphFormat()->set_Alignment(ParagraphAlignment::Center);
builder->get_CellFormat()->ClearFormatting();
builder->get_CellFormat()->set_Width(150);
builder->get_CellFormat()->set_VerticalAlignment(CellVerticalAlignment::Center);
builder->get_CellFormat()->get_Shading()->set_BackgroundPatternColor(System::Drawing::Color::get_GreenYellow());
builder->get_CellFormat()->set_WrapText(false);
builder->get_CellFormat()->set_FitText(true);
builder->get_RowFormat()->ClearFormatting();
builder->get_RowFormat()->set_HeightRule(HeightRule::Exactly);
builder->get_RowFormat()->set_Height(50);
builder->get_RowFormat()->get_Borders()->set_LineStyle(LineStyle::Engrave3D);
builder->get_RowFormat()->get_Borders()->set_Color(System::Drawing::Color::get_Orange());
builder->InsertCell();
builder->Write(u"Row 1, Col 1");
builder->InsertCell();
builder->Write(u"Row 1, Col 2");
builder->EndRow();
// Changing the formatting will apply it to the current cell,
// and any new cells that we create with the builder afterward.
// This will not affect the cells that we have added previously.
builder->get_CellFormat()->get_Shading()->ClearFormatting();
builder->InsertCell();
builder->Write(u"Row 2, Col 1");
builder->InsertCell();
builder->Write(u"Row 2, Col 2");
builder->EndRow();
// Increase row height to fit the vertical text.
builder->InsertCell();
builder->get_RowFormat()->set_Height(150);
builder->get_CellFormat()->set_Orientation(TextOrientation::Upward);
builder->Write(u"Row 3, Col 1");
builder->InsertCell();
builder->get_CellFormat()->set_Orientation(TextOrientation::Downward);
builder->Write(u"Row 3, Col 2");
builder->EndRow();
builder->EndTable();
doc->Save(ArtifactsDir + u"DocumentBuilder.InsertTable.docx");

Shows how to format cells with a document builder.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
SharedPtr<Table> table = builder->StartTable();
builder->InsertCell();
builder->Write(u"Row 1, cell 1.");
// Insert a second cell, and then configure cell text padding options.
// The builder will apply these settings at its current cell, and any new cells creates afterwards.
builder->InsertCell();
SharedPtr<CellFormat> cellFormat = builder->get_CellFormat();
cellFormat->set_Width(250);
cellFormat->set_LeftPadding(30);
cellFormat->set_RightPadding(30);
cellFormat->set_TopPadding(30);
cellFormat->set_BottomPadding(30);
builder->Write(u"Row 1, cell 2.");
builder->EndRow();
builder->EndTable();
// The first cell was unaffected by the padding reconfiguration, and still holds the default values.
ASPOSE_ASSERT_EQ(0.0, table->get_FirstRow()->get_Cells()->idx_get(0)->get_CellFormat()->get_Width());
ASPOSE_ASSERT_EQ(5.4, table->get_FirstRow()->get_Cells()->idx_get(0)->get_CellFormat()->get_LeftPadding());
ASPOSE_ASSERT_EQ(5.4, table->get_FirstRow()->get_Cells()->idx_get(0)->get_CellFormat()->get_RightPadding());
ASPOSE_ASSERT_EQ(0.0, table->get_FirstRow()->get_Cells()->idx_get(0)->get_CellFormat()->get_TopPadding());
ASPOSE_ASSERT_EQ(0.0, table->get_FirstRow()->get_Cells()->idx_get(0)->get_CellFormat()->get_BottomPadding());
ASPOSE_ASSERT_EQ(250.0, table->get_FirstRow()->get_Cells()->idx_get(1)->get_CellFormat()->get_Width());
ASPOSE_ASSERT_EQ(30.0, table->get_FirstRow()->get_Cells()->idx_get(1)->get_CellFormat()->get_LeftPadding());
ASPOSE_ASSERT_EQ(30.0, table->get_FirstRow()->get_Cells()->idx_get(1)->get_CellFormat()->get_RightPadding());
ASPOSE_ASSERT_EQ(30.0, table->get_FirstRow()->get_Cells()->idx_get(1)->get_CellFormat()->get_TopPadding());
ASPOSE_ASSERT_EQ(30.0, table->get_FirstRow()->get_Cells()->idx_get(1)->get_CellFormat()->get_BottomPadding());
// The first cell will still grow in the output document to match the size of its neighboring cell.
doc->Save(ArtifactsDir + u"DocumentBuilder.SetCellFormatting.docx");

◆ get_WrapText()

bool Aspose::Words::Tables::CellFormat::get_WrapText ( )

If true, wrap text for the cell.

Examples

Shows how to build a table with custom borders.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
builder->StartTable();
// Setting table formatting options for a document builder
// will apply them to every row and cell that we add with it.
builder->get_ParagraphFormat()->set_Alignment(ParagraphAlignment::Center);
builder->get_CellFormat()->ClearFormatting();
builder->get_CellFormat()->set_Width(150);
builder->get_CellFormat()->set_VerticalAlignment(CellVerticalAlignment::Center);
builder->get_CellFormat()->get_Shading()->set_BackgroundPatternColor(System::Drawing::Color::get_GreenYellow());
builder->get_CellFormat()->set_WrapText(false);
builder->get_CellFormat()->set_FitText(true);
builder->get_RowFormat()->ClearFormatting();
builder->get_RowFormat()->set_HeightRule(HeightRule::Exactly);
builder->get_RowFormat()->set_Height(50);
builder->get_RowFormat()->get_Borders()->set_LineStyle(LineStyle::Engrave3D);
builder->get_RowFormat()->get_Borders()->set_Color(System::Drawing::Color::get_Orange());
builder->InsertCell();
builder->Write(u"Row 1, Col 1");
builder->InsertCell();
builder->Write(u"Row 1, Col 2");
builder->EndRow();
// Changing the formatting will apply it to the current cell,
// and any new cells that we create with the builder afterward.
// This will not affect the cells that we have added previously.
builder->get_CellFormat()->get_Shading()->ClearFormatting();
builder->InsertCell();
builder->Write(u"Row 2, Col 1");
builder->InsertCell();
builder->Write(u"Row 2, Col 2");
builder->EndRow();
// Increase row height to fit the vertical text.
builder->InsertCell();
builder->get_RowFormat()->set_Height(150);
builder->get_CellFormat()->set_Orientation(TextOrientation::Upward);
builder->Write(u"Row 3, Col 1");
builder->InsertCell();
builder->get_CellFormat()->set_Orientation(TextOrientation::Downward);
builder->Write(u"Row 3, Col 2");
builder->EndRow();
builder->EndTable();
doc->Save(ArtifactsDir + u"DocumentBuilder.InsertTable.docx");

◆ GetType()

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

◆ Is()

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

◆ set_BottomPadding()

void Aspose::Words::Tables::CellFormat::set_BottomPadding ( double  value)

◆ set_FitText()

void Aspose::Words::Tables::CellFormat::set_FitText ( bool  value)

◆ set_HorizontalMerge()

void Aspose::Words::Tables::CellFormat::set_HorizontalMerge ( Aspose::Words::Tables::CellMerge  value)

◆ set_LeftPadding()

void Aspose::Words::Tables::CellFormat::set_LeftPadding ( double  value)

◆ set_Orientation()

void Aspose::Words::Tables::CellFormat::set_Orientation ( Aspose::Words::TextOrientation  value)

◆ set_PreferredWidth()

void Aspose::Words::Tables::CellFormat::set_PreferredWidth ( System::SharedPtr< Aspose::Words::Tables::PreferredWidth value)

◆ set_RightPadding()

void Aspose::Words::Tables::CellFormat::set_RightPadding ( double  value)

◆ set_TopPadding()

void Aspose::Words::Tables::CellFormat::set_TopPadding ( double  value)

◆ set_VerticalAlignment()

void Aspose::Words::Tables::CellFormat::set_VerticalAlignment ( Aspose::Words::Tables::CellVerticalAlignment  value)

◆ set_VerticalMerge()

void Aspose::Words::Tables::CellFormat::set_VerticalMerge ( Aspose::Words::Tables::CellMerge  value)

◆ set_Width()

void Aspose::Words::Tables::CellFormat::set_Width ( double  value)

◆ set_WrapText()

void Aspose::Words::Tables::CellFormat::set_WrapText ( bool  value)

◆ SetPaddings()

void Aspose::Words::Tables::CellFormat::SetPaddings ( double  leftPadding,
double  topPadding,
double  rightPadding,
double  bottomPadding 
)

Sets the amount of space (in points) to add to the left/top/right/bottom of the contents of cell.

Examples

Shows how to pad the contents of a cell with whitespace.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Set a padding distance (in points) between the border and the text contents
// of each table cell we create with the document builder.
builder->get_CellFormat()->SetPaddings(5, 10, 40, 50);
// Create a table with one cell whose contents will have whitespace padding.
builder->StartTable();
builder->InsertCell();
builder->Write(String(u"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. ") +
u"Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.");
doc->Save(ArtifactsDir + u"CellFormat.Padding.docx");

◆ Type()

static const System::TypeInfo& Aspose::Words::Tables::CellFormat::Type ( )
static