Class RowFormat
Represents the formatting properties for the table and row in a Word document.
Implements
Inherited Members
Namespace: Syncfusion.DocIO.DLS
Assembly: Syncfusion.DocIO.NET.dll
Syntax
public class RowFormat : FormatBase, IXDLSSerializable
Examples
The following example illustrates how to apply table formatting options such as Borders, LeftIndent, Paddings, IsAutoResize, etc.
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create an instance of WordDocument class (Empty Word Document)
WordDocument document = new WordDocument();
//Open an existing Word document into DocIO instance
document.Open("Table.docx", FormatType.Docx);
//Access the instance of the first section in the Word document
WSection section = document.Sections[0];
//Access the instance of the first table in the section
WTable table = section.Tables[0] as WTable;
//Specify the title for the table
table.Title ="PriceDetails";
//Specify the description of the table
table.Description = "This table shows the price details of various fruits";
//Specify the left indent of the table
table.IndentFromLeft = 50;
//Specify the background color of the table
table.TableFormat.BackColor = Color.FromArgb(192, 192, 192);
//Specify the horizontal alignment of the table
table.TableFormat.HorizontalAlignment = RowAlignment.Left;
//Specify the left, right, top and bottom padding of all the cells in the table
table.TableFormat.Paddings.All = 10;
//Specify the auto resize of table to automatically resize all cell width based on its content
table.TableFormat.IsAutoResized = true;
//Specify the table top, bottom, left and right border line width
table.TableFormat.Borders.LineWidth = 2f;
//Specify the table horizontal border line width
table.TableFormat.Borders.Horizontal.LineWidth = 2f;
//Specify the table vertical border line width
table.TableFormat.Borders.Vertical.LineWidth = 2f;
//Specify the tables top, bottom, left and right border color
table.TableFormat.Borders.Color = Color.Red;
//Specify the table Horizontal border color
table.TableFormat.Borders.Horizontal.Color = Color.Red;
//Specify the table vertical border color
table.TableFormat.Borders.Vertical.Color = Color.Red;
//Specify the table borders border type
table.TableFormat.Borders.BorderType = BorderStyle.Double;
//Access the instance of the first row in the table
WTableRow row = table.Rows[0];
//Specify the row height
row.Height = 20;
//Specify the row height type
row.HeightType = TableRowHeightType.AtLeast;
document.Save("TableFormatting.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create an instance of WordDocument class (Empty Word Document)
Dim document As New WordDocument()
'Open an existing Word document into DocIO instance
document.Open("Table.docx", FormatType.Docx)
'Access the instance of the first section in the Word document
Dim section As WSection = document.Sections(0)
'Access the instance of the first table in the section
Dim table As WTable = TryCast(section.Tables(0), WTable)
'Specify the title for the table
table.Title = "PriceDetails"
'Specify the description of the table
table.Description = "This table shows the price details of various fruits"
'Specify the left indent of the table
table.IndentFromLeft = 50
'Specify the background color of the table
table.TableFormat.BackColor = Color.FromArgb(192, 192, 192)
'Specify the horizontal alignment of the table
table.TableFormat.HorizontalAlignment = RowAlignment.Left
'Specify the left, right, top and bottom padding of all the cells in the table
table.TableFormat.Paddings.All = 10
'Specify the auto resize of table to automatically resize all cell width based on its content
table.TableFormat.IsAutoResized = True
'Specify the table top, bottom, left and right border line width
table.TableFormat.Borders.LineWidth = 2.0F
'Specify the table horizontal border line width
table.TableFormat.Borders.Horizontal.LineWidth = 2.0F
'Specify the table vertical border line width
table.TableFormat.Borders.Vertical.LineWidth = 2.0F
'Specify the tables top, bottom, left and right border color
table.TableFormat.Borders.Color = Color.Red
'Specify the table Horizontal border color
table.TableFormat.Borders.Horizontal.Color = Color.Red
'Specify the table vertical border color
table.TableFormat.Borders.Vertical.Color = Color.Red
'Specify the table borders border type
table.TableFormat.Borders.BorderType = BorderStyle.[Double]
'Access the instance of the first row in the table
Dim row As WTableRow = table.Rows(0)
'Specify the row height
row.Height = 20
'Specify the row height type
row.HeightType = TableRowHeightType.AtLeast
document.Save("TableFormatting.docx", FormatType.Docx)
document.Close()
End Sub
Constructors
RowFormat()
Initializes a new instance of the RowFormat class.
Declaration
public RowFormat()
Properties
BackColor
Gets or sets background color for the table or table row.
Declaration
public Color BackColor { get; set; }
Property Value
Type | Description |
---|---|
Color | The System.Drawing.Color for the background of table or row. |
Remarks
When the table has no background color, the background color of the first row will be applied to the entire table.
Bidi
Gets or sets a value indicating whether the table is a right to left table.
Declaration
public bool Bidi { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | True if the table is right to left table; otherwise, false. |
Borders
Gets the borders for the table or table row. Read-only
Declaration
public Borders Borders { get; }
Property Value
Type | Description |
---|---|
Borders | The Borders for the table or row. |
Remarks
The borders specified for the first row in the table will be applied to the entire table when the table has no borders.
CellSpacing
Gets or sets spacing value between the cells in the table or table row.
Declaration
public float CellSpacing { get; set; }
Property Value
Type | Description |
---|---|
System.Single | The float that specifies the spacing value. |
HorizontalAlignment
Gets or sets horizontal alignment for the table.
Declaration
public RowAlignment HorizontalAlignment { get; set; }
Property Value
Type | Description |
---|---|
RowAlignment | The RowAlignment member that specifies the horizontal alignment for table. |
IsAutoResized
Gets or sets the value indicating whether the table is auto resized based on contents.
Declaration
public bool IsAutoResized { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | True if automatically resize to fit contents; otherwise false. |
IsBreakAcrossPages
Gets or sets the value indicating whether the row can break across pages.
Declaration
public bool IsBreakAcrossPages { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | True if the row can break across pages; otherwise, false. |
Examples
private void Button1_Click(System.Object sender, System.EventArgs e)
{
WordDocument document = new WordDocument("Template.docx");
WSection section = document.Sections[0];
WTable table = section.Tables[0] as WTable;
//Disable breaking across pages for all rows in the table.
foreach (WTableRow row in table.Rows)
row.RowFormat.IsBreakAcrossPages = false;
document.Save("Result.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
Dim document As New WordDocument("Template.docx")
Dim section As WSection = document.Sections(0)
Dim table As WTable = TryCast(section.Tables(0), WTable)
'Disable breaking across pages for all rows in the table.
For Each row As WTableRow In table.Rows
row.RowFormat.IsBreakAcrossPages = False
Next
document.Save("Result.docx", FormatType.Docx)
document.Close()
End Sub
LeftIndent
Gets or sets the value for table left indent.
Declaration
public float LeftIndent { get; set; }
Property Value
Type | Description |
---|---|
System.Single | The float that specifies the left indent value. |
Paddings
Gets the Paddings for the table. Read-only.
Declaration
public Paddings Paddings { get; }
Property Value
Type | Description |
---|---|
Paddings | The Paddings instance that specifies the cell padding values for the entire table. |
Positioning
Gets the positioning values of the table when the text wrapping type is around. Read-only.
Declaration
public RowFormat.TablePositioning Positioning { get; }
Property Value
Type | Description |
---|---|
RowFormat.TablePositioning | The RowFormat.TablePositioning object that specifies the absolute position of the table. |
WrapTextAround
Gets or sets a value indicating whether to use Around text wrapping.
Declaration
public bool WrapTextAround { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | True if wrap table around text; otherwise, false. |
Methods
EnsureComposites()
Ensures the composites.
Declaration
protected override void EnsureComposites()
Overrides
GetDefComposite(Int32)
Returns the composite values.
Declaration
protected override FormatBase GetDefComposite(int key)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | key | The integer that specifies the key. |
Returns
Type | Description |
---|---|
FormatBase | The FormatBase object. |
Overrides
GetDefValue(Int32)
Returns the default values.
Declaration
protected override object GetDefValue(int key)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | key | The integer that specifies the key. |
Returns
Type | Description |
---|---|
System.Object | An object that specifies the default value. |
Overrides
ImportContainer(FormatBase)
Imports the container.
Declaration
protected void ImportContainer(FormatBase format)
Parameters
Type | Name | Description |
---|---|---|
FormatBase | format | The FormatBase object. |
ImportMembers(FormatBase)
Imports the members.
Declaration
protected override void ImportMembers(FormatBase format)
Parameters
Type | Name | Description |
---|---|---|
FormatBase | format | The FormatBase object. |
Overrides
InitXDLSHolder()
Registers child objects in XDSL holder.
Declaration
protected override void InitXDLSHolder()
Overrides
OnChange(FormatBase, Int32)
Occurs on format change.
Declaration
protected override void OnChange(FormatBase format, int propKey)
Parameters
Type | Name | Description |
---|---|---|
FormatBase | format | The FormatBase object. |
System.Int32 | propKey | The integer that represents the property key. |
Overrides
ReadXmlAttributes(IXDLSAttributeReader)
Reads object data from xml attributes.
Declaration
protected override void ReadXmlAttributes(IXDLSAttributeReader reader)
Parameters
Type | Name | Description |
---|---|---|
IXDLSAttributeReader | reader | The IXDLSAttributeReader object. |
Overrides
ReadXmlContent(IXDLSContentReader)
Reads object data from xml attributes.
Declaration
protected override bool ReadXmlContent(IXDLSContentReader reader)
Parameters
Type | Name | Description |
---|---|---|
IXDLSContentReader | reader | The IXDLSContentReader object. |
Returns
Type | Description |
---|---|
System.Boolean | The value indicating the presence of xml content. |
Overrides
WriteXmlAttributes(IXDLSAttributeWriter)
Writes object data as xml attributes.
Declaration
protected override void WriteXmlAttributes(IXDLSAttributeWriter writer)
Parameters
Type | Name | Description |
---|---|---|
IXDLSAttributeWriter | writer | The IXDLSAttributeWriter object. |
Overrides
WriteXmlContent(IXDLSContentWriter)
Writes object data as inside xml element.
Declaration
protected override void WriteXmlContent(IXDLSContentWriter writer)
Parameters
Type | Name | Description |
---|---|---|
IXDLSContentWriter | writer | The IXDLSContentWriter object. |