preferred_width property

Table.preferred_width property

Gets or sets the table preferred width.

@property
def preferred_width(self) -> aspose.words.tables.PreferredWidth:
    ...

@preferred_width.setter
def preferred_width(self, value: aspose.words.tables.PreferredWidth):
    ...

Remarks

The default value is PreferredWidth.AUTO.

Examples

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

doc = aw.Document()
builder = aw.DocumentBuilder(doc)

table = builder.start_table()
builder.insert_cell()
builder.write("Cell #1")
builder.insert_cell()
builder.write("Cell #2")
builder.insert_cell()
builder.write("Cell #3")

table.preferred_width = aw.tables.PreferredWidth.from_percent(50)

doc.save(ARTIFACTS_DIR + "DocumentBuilder.insert_table_with_preferred_width.docx")

See Also