Aspose::Words::Tables::Table::get_PreferredWidth method

Table::get_PreferredWidth method

Gets or sets the table preferred width.

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

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 = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);

SharedPtr<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(ArtifactsDir + u"DocumentBuilder.InsertTableWithPreferredWidth.docx");

See Also