Class CellFormat
Represents the cell formatting options for table cell.
Implements
Inherited Members
Namespace: Syncfusion.DocIO.DLS
Assembly: Syncfusion.DocIO.Base.dll
Syntax
public class CellFormat : FormatBase, IXDLSSerializableExamples
The following code example demonstrates how to apply cell formatting options to a WTableCell
private void Button1_Click(System.Object sender, System.EventArgs e)
{
    WordDocument document = new WordDocument();
    document.Open("Table.docx", FormatType.Docx);
    WSection section = document.Sections[0];
    WTable table = section.Tables[0] as WTable;
    //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;
    //Access the instance of the first cell in the row
    WTableCell cell = row.Cells[0];
    //Specify the cell back ground color
    cell.CellFormat.BackColor = Color.FromArgb(192, 192, 192);
    //Specify the same padding as table option as false to preserve current cell padding
    cell.CellFormat.SamePaddingsAsTable = false;
    //Specify the left, right, top and bottom padding of the cell
    cell.CellFormat.Paddings.Left = 5;
    cell.CellFormat.Paddings.Right = 5;
    cell.CellFormat.Paddings.Top = 5;
    cell.CellFormat.Paddings.Bottom = 5;
    //Specify the vertical alignment of content of text
    cell.CellFormat.VerticalAlignment = VerticalAlignment.Middle;
    //Access the instance of the second cell in the row
    cell = row.Cells[1];
    cell.CellFormat.BackColor = Color.FromArgb(192, 192, 192);
    cell.CellFormat.SamePaddingsAsTable = false;
    //Specify the left, right, top and bottom padding of the cell
    cell.CellFormat.Paddings.All = 5;
    cell.CellFormat.VerticalAlignment = VerticalAlignment.Middle;
    document.Save("TableCellFormatting.docx", FormatType.Docx);
    document.Close();
}Private Sub button_Click(sender As Object, e As EventArgs)
    Dim document As New WordDocument()
    document.Open("Table.docx", FormatType.Docx)
    Dim section As WSection = document.Sections(0)
    Dim table As WTable = TryCast(section.Tables(0), WTable)
    '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
    'Access the instance of the first cell in the row
    Dim cell As WTableCell = row.Cells(0)
    'Specify the cell back ground color
    cell.CellFormat.BackColor = Color.FromArgb(192, 192, 192)
    'Specify the same padding as table option as false to preserve current cell padding
    cell.CellFormat.SamePaddingsAsTable = False
    'Specify the left, right, top and bottom padding of the cell
    cell.CellFormat.Paddings.Left = 5
    cell.CellFormat.Paddings.Right = 5
    cell.CellFormat.Paddings.Top = 5
    cell.CellFormat.Paddings.Bottom = 5
    'Specify the vertical alignment of content of text
    cell.CellFormat.VerticalAlignment = VerticalAlignment.Middle
    'Access the instance of the second cell in the row
    cell = row.Cells(1)
    cell.CellFormat.BackColor = Color.FromArgb(192, 192, 192)
    cell.CellFormat.SamePaddingsAsTable = False
    'Specify the left, right, top and bottom padding of the cell
    cell.CellFormat.Paddings.All = 5
    cell.CellFormat.VerticalAlignment = VerticalAlignment.Middle
    document.Save("TableCellFormatting.docx", FormatType.Docx)
    document.Close()
End SubConstructors
CellFormat()
Initializes a new instance of the CellFormat class.
Declaration
public CellFormat()Properties
BackColor
Gets or sets the background color for cell.
Declaration
public Color BackColor { get; set; }Property Value
| Type | Description | 
|---|---|
| System.Drawing.Color | The System.Drawing.Color for cell background. | 
Borders
Gets the borders for the cell.
Declaration
public Borders Borders { get; }Property Value
| Type | Description | 
|---|---|
| Borders | The Borders that specifies the borders of the cell. | 
FitText
Gets or sets fit text option of the cell.
Declaration
public bool FitText { get; set; }Property Value
| Type | Description | 
|---|---|
| System.Boolean | True if the fit text option is enabled; otherwise, false. | 
HorizontalMerge
Gets or sets the way of combining of the cell horizontally.
Declaration
public CellMerge HorizontalMerge { get; set; }Property Value
| Type | Description | 
|---|---|
| CellMerge | The CellMerge member that specifies the way of horizontal merging. | 
Paddings
Gets the cell paddings. Read-only.
Declaration
public Paddings Paddings { get; }Property Value
| Type | Description | 
|---|---|
| Paddings | The Paddings for the cell. | 
SamePaddingsAsTable
Gets or sets value indicating whether to use same paddings as the table.
Declaration
public bool SamePaddingsAsTable { get; set; }Property Value
| Type | Description | 
|---|---|
| System.Boolean | True if it has same padding values as table; otherwise, false. | 
TextDirection
Gets or sets cell text direction.
Declaration
public TextDirection TextDirection { get; set; }Property Value
| Type | Description | 
|---|---|
| TextDirection | The TextDirection member that specifies the type of text direction. | 
TextWrap
Gets or sets a value indicating whether the text wrapping is set.
Declaration
public bool TextWrap { get; set; }Property Value
| Type | Description | 
|---|---|
| System.Boolean | 
 | 
VerticalAlignment
Gets or sets the vertical alignment of the cell content.
Declaration
public VerticalAlignment VerticalAlignment { get; set; }Property Value
| Type | Description | 
|---|---|
| VerticalAlignment | The VerticalAlignment member that specifies the vertical alignment of cell content. | 
VerticalMerge
Gets or sets the way of combining of the cell vertically.
Declaration
public CellMerge VerticalMerge { get; set; }Property Value
| Type | Description | 
|---|---|
| CellMerge | The CellMerge member that specifies the way of vertical merging. | 
Methods
EnsureComposites()
Ensures the composites.
Declaration
protected override void EnsureComposites()Overrides
GetDefComposite(Int32)
Gets 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 specifying the key value of the property. | 
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
WriteXmlAttributes(IXDLSAttributeWriter)
Writes object data as xml attributes.
Declaration
protected override void WriteXmlAttributes(IXDLSAttributeWriter writer)Parameters
| Type | Name | Description | 
|---|---|---|
| IXDLSAttributeWriter | writer | The IXDLSAttributeWriter object. |