Aspose::Words::Tables::CellFormat::get_RightPadding method

CellFormat::get_RightPadding method

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

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

Examples

Shows how to format cells with a document builder.

auto doc = System::MakeObject<Aspose::Words::Document>();
auto builder = System::MakeObject<Aspose::Words::DocumentBuilder>(doc);

System::SharedPtr<Aspose::Words::Tables::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();

System::SharedPtr<Aspose::Words::Tables::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(table->get_FirstRow()->get_Cells()->idx_get(0)->get_CellFormat()->get_Width(), 0.0);
ASPOSE_ASSERT_EQ(table->get_FirstRow()->get_Cells()->idx_get(0)->get_CellFormat()->get_LeftPadding(), 5.4);
ASPOSE_ASSERT_EQ(table->get_FirstRow()->get_Cells()->idx_get(0)->get_CellFormat()->get_RightPadding(), 5.4);
ASPOSE_ASSERT_EQ(table->get_FirstRow()->get_Cells()->idx_get(0)->get_CellFormat()->get_TopPadding(), 0.0);
ASPOSE_ASSERT_EQ(table->get_FirstRow()->get_Cells()->idx_get(0)->get_CellFormat()->get_BottomPadding(), 0.0);

ASPOSE_ASSERT_EQ(table->get_FirstRow()->get_Cells()->idx_get(1)->get_CellFormat()->get_Width(), 250.0);
ASPOSE_ASSERT_EQ(table->get_FirstRow()->get_Cells()->idx_get(1)->get_CellFormat()->get_LeftPadding(), 30.0);
ASPOSE_ASSERT_EQ(table->get_FirstRow()->get_Cells()->idx_get(1)->get_CellFormat()->get_RightPadding(), 30.0);
ASPOSE_ASSERT_EQ(table->get_FirstRow()->get_Cells()->idx_get(1)->get_CellFormat()->get_TopPadding(), 30.0);
ASPOSE_ASSERT_EQ(table->get_FirstRow()->get_Cells()->idx_get(1)->get_CellFormat()->get_BottomPadding(), 30.0);

// The first cell will still grow in the output document to match the size of its neighboring cell.
doc->Save(get_ArtifactsDir() + u"DocumentBuilder.SetCellFormatting.docx");

See Also