RowFormat Class
Represents all formatting for a table row.
Inheritance Hierarchy

Namespace: Aspose.Words.Tables
Assembly: Aspose.Words (in Aspose.Words.dll) Version: 20.1
public class RowFormat

The RowFormat type exposes the following members.

Public propertyCode exampleAllowBreakAcrossPages
True if the text in a table row is allowed to split across a page break.
Public propertyCode exampleBorders
Gets the collection of default cell borders for the row.
Public propertyCode exampleHeadingFormat
True if the row is repeated as a table heading on every page when the table spans more than one page.
Public propertyCode exampleHeight
Gets or sets the height of the table row in points.
Public propertyCode exampleHeightRule
Gets or sets the rule for determining the height of the table row.
Public methodCode exampleClearFormatting
Resets to default row formatting.
Public methodEquals (Inherited from Object.)
Protected methodFinalize (Inherited from Object.)
Public methodGetHashCode (Inherited from Object.)
Public methodGetType (Inherited from Object.)
Protected methodMemberwiseClone (Inherited from Object.)
Public methodToString (Inherited from Object.)
Shows how to modify formatting of a table row.
Document doc = new Document(MyDir + "Table.Document.doc");
Table table = (Table) doc.GetChild(NodeType.Table, 0, true);

// Retrieve the first row in the table
Row firstRow = table.FirstRow;

// Modify some row level properties
firstRow.RowFormat.Borders.LineStyle = LineStyle.None;
firstRow.RowFormat.HeightRule = HeightRule.Auto;
firstRow.RowFormat.AllowBreakAcrossPages = true;
Shows how to build a nice bordered table.
DocumentBuilder builder = new DocumentBuilder();

// Start building a table

// Set the appropriate paragraph, cell, and row formatting. The formatting properties are preserved
// until they are explicitly modified so there's no need to set them for each row or cell
builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;

builder.CellFormat.Width = 150;
builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
builder.CellFormat.Shading.BackgroundPatternColor = Color.GreenYellow;
builder.CellFormat.WrapText = false;
builder.CellFormat.FitText = true;

builder.RowFormat.HeightRule = HeightRule.Exactly;
builder.RowFormat.Height = 50;
builder.RowFormat.Borders.LineStyle = LineStyle.Engrave3D;
builder.RowFormat.Borders.Color = Color.Orange;

builder.Write("Row 1, Col 1");

builder.Write("Row 1, Col 2");


// Remove the shading (clear background)

builder.Write("Row 2, Col 1");

builder.Write("Row 2, Col 2");



// Make the row height bigger so that a vertically oriented text could fit into cells
builder.RowFormat.Height = 150;
builder.CellFormat.Orientation = TextOrientation.Upward;
builder.Write("Row 3, Col 1");

builder.CellFormat.Orientation = TextOrientation.Downward;
builder.Write("Row 3, Col 2");



builder.Document.Save(ArtifactsDir + "DocumentBuilder.InsertTable.docx");
Shows how to insert a table using the constructors of nodes.
Document doc = new Document();

// We start by creating the table object. Note how we must pass the document object
// to the constructor of each node. This is because every node we create must belong
// to some document
Table table = new Table(doc);
// Add the table to the document

// Here we could call EnsureMinimum to create the rows and cells for us. This method is used
// to ensure that the specified node is valid, in this case a valid table should have at least one
// row and one cell, therefore this method creates them for us

// Instead we will handle creating the row and table ourselves. This would be the best way to do this
// if we were creating a table inside an algorithm for example
Row row = new Row(doc);
row.RowFormat.AllowBreakAcrossPages = true;

// We can now apply any auto fit settings

// Create a cell and add it to the row
Cell cell = new Cell(doc);
cell.CellFormat.Shading.BackgroundPatternColor = Color.LightBlue;
cell.CellFormat.Width = 80;

// Add a paragraph to the cell as well as a new run with some text
cell.AppendChild(new Paragraph(doc));
cell.FirstParagraph.AppendChild(new Run(doc, "Row 1, Cell 1 Text"));

// Add the cell to the row

// We would then repeat the process for the other cells and rows in the table
// We can also speed things up by cloning existing cells and rows
row.LastCell.AppendChild(new Paragraph(doc));
row.LastCell.FirstParagraph.AppendChild(new Run(doc, "Row 1, Cell 2 Text"));

// Remove spacing between cells
table.AllowCellSpacing = false;

doc.Save(ArtifactsDir + "Table.InsertTableUsingNodes.doc");
See Also