The height of a table row is controlled using height and height rule properties. These can be set differently for each row in the table which allows for wide control over the height of each row.
In Aspose.Words these are represented by the RowFormat.Height and RowFormat.HeightRule properties of the given Row.
HeightRule Value |
Description |
Auto |
This is the default height rule given to a new row. Technically this means that no height rule is defined. The row is sized to fit the largest content within the cells of the row. |
At Least |
With this setting the height of the row will grow to accommodate the content of the row, but will never be smaller than the specified size in RowFormat.Height. |
Exactly |
The size of the row is set exactly to the value found in RowFormat.Height and does not grow to fit content. |
The simplest way to set row height is using DocumentBuilder. Using the appropriate RowFormat properties you can set a default height setting or apply a different height for each row in the table.
Example
Shows how to create a table that contains a single cell and apply row formatting.
[Java]
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
Table table = builder.startTable();
builder.insertCell();
// Set the row formatting
RowFormat rowFormat = builder.getRowFormat();
rowFormat.setHeight(100);
rowFormat.setHeightRule(HeightRule.EXACTLY);
// These formatting properties are set on the table and are applied to all rows in the table.
table.setLeftPadding(30);
table.setRightPadding(30);
table.setTopPadding(30);
table.setBottomPadding(30);
builder.writeln("I'm a wonderful formatted row.");
builder.endRow();
builder.endTable();