RowFormatHeightRule Property

Gets or sets the rule for determining the height of the table row.

Namespace:  Aspose.Words.Tables
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 20.3
Syntax
public HeightRule HeightRule { get; set; }

Property Value

Type: HeightRule
Examples
Shows how to create a table that contains a single cell and apply row formatting.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

Table table = builder.StartTable();
builder.InsertCell();

// Set the row formatting
RowFormat rowFormat = builder.RowFormat;
rowFormat.Height = 100;
rowFormat.HeightRule = HeightRule.Exactly;
// These formatting properties are set on the table and are applied to all rows in the table
table.LeftPadding = 30;
table.RightPadding = 30;
table.TopPadding = 30;
table.BottomPadding = 30;

builder.Writeln("Contents of formatted row.");

builder.EndRow();
builder.EndTable();
Examples
Shows how to create a formatted table using DocumentBuilder.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

Table table = builder.StartTable();

// Make the header row
builder.InsertCell();

// Set the left indent for the table. Table wide formatting must be applied after 
// at least one row is present in the table
table.LeftIndent = 20.0;

// Set height and define the height rule for the header row
builder.RowFormat.Height = 40.0;
builder.RowFormat.HeightRule = HeightRule.AtLeast;

// Some special features for the header row
builder.CellFormat.Shading.BackgroundPatternColor = Color.FromArgb(198, 217, 241);
builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
builder.Font.Size = 16;
builder.Font.Name = "Arial";
builder.Font.Bold = true;

builder.CellFormat.Width = 100.0;
builder.Write("Header Row,\n Cell 1");

// We don't need to specify the width of this cell because it's inherited from the previous cell
builder.InsertCell();
builder.Write("Header Row,\n Cell 2");

builder.InsertCell();
builder.CellFormat.Width = 200.0;
builder.Write("Header Row,\n Cell 3");
builder.EndRow();

// Set features for the other rows and cells
builder.CellFormat.Shading.BackgroundPatternColor = Color.White;
builder.CellFormat.Width = 100.0;
builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;

// Reset height and define a different height rule for table body
builder.RowFormat.Height = 30.0;
builder.RowFormat.HeightRule = HeightRule.Auto;
builder.InsertCell();
// Reset font formatting
builder.Font.Size = 12;
builder.Font.Bold = false;

// Build the other cells
builder.Write("Row 1, Cell 1 Content");
builder.InsertCell();
builder.Write("Row 1, Cell 2 Content");

builder.InsertCell();
builder.CellFormat.Width = 200.0;
builder.Write("Row 1, Cell 3 Content");
builder.EndRow();

builder.InsertCell();
builder.CellFormat.Width = 100.0;
builder.Write("Row 2, Cell 1 Content");

builder.InsertCell();
builder.Write("Row 2, Cell 2 Content");

builder.InsertCell();
builder.CellFormat.Width = 200.0;
builder.Write("Row 2, Cell 3 Content.");
builder.EndRow();
builder.EndTable();

doc.Save(ArtifactsDir + "DocumentBuilder.CreateFormattedTable.doc");
See Also