Aspose::Words::Tables::Table::set_PreferredWidth method

Table::set_PreferredWidth method

Sets the table preferred width.

void Aspose::Words::Tables::Table::set_PreferredWidth(const System::SharedPtr<Aspose::Words::Tables::PreferredWidth> & value)

Remarks

The default value is Auto.

Examples

Shows how to set a table to auto fit to 50% of the width of the page.

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"Cell #1");
builder->InsertCell();
builder->Write(u"Cell #2");
builder->InsertCell();
builder->Write(u"Cell #3");

table->set_PreferredWidth(PreferredWidth::FromPercent(50));

doc->Save(get_ArtifactsDir() + u"DocumentBuilder.InsertTableWithPreferredWidth.docx");

See Also