allowAutoFit property

Table.allowAutoFit property

Allows Microsoft Word and Aspose.Words to automatically resize cells in a table to fit their contents.

get allowAutoFit(): boolean

Remarks

The default value is true.

Examples

Shows how to enable/disable automatic table cell resizing.

let doc = new aw.Document();
let builder = new aw.DocumentBuilder(doc);

let table = builder.startTable();
builder.insertCell();
builder.cellFormat.preferredWidth = aw.Tables.PreferredWidth.fromPoints(100);
builder.write("Lorem ipsum dolor sit amet, consectetur adipiscing elit, " +
      "sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.");

builder.insertCell();
builder.cellFormat.preferredWidth = aw.Tables.PreferredWidth.auto;
builder.write("Lorem ipsum dolor sit amet, consectetur adipiscing elit, " +
      "sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.");
builder.endRow();
builder.endTable();

// Set the "AllowAutoFit" property to "false" to get the table to maintain the dimensions
// of all its rows and cells, and truncate contents if they get too large to fit.
// Set the "AllowAutoFit" property to "true" to allow the table to change its cells' width and height
// to accommodate their contents.
table.allowAutoFit = allowAutoFit;

doc.save(base.artifactsDir + "Table.AllowAutoFitOnTable.html");

See Also