The TableFormatting class is used to specify formatting that should be applied to a table. It also represents the table formatting of some named styles in the document.

 public sealed class TableFormatting
Public NotInheritable Class TableFormatting

There are two ways to obtain an instance of this class: Create a new normal table formatting object using Document.CreateTableFormatting(). This will return a copy of a particular style's table formatting. The TableFormatting object that is returned can then be used in conjunction with methods in the Element class to create tables with specific formatting.

The following example demonstrates both ways of getting table formatting, first by retrieving the NormalTable style's paragraph formatting from the document, second by retrieving a copy of the TableSimple1 style's paragraph formatting.


          //--- Get NormalTable formatting from Document
          WordApplication app = new WordApplication();
          Document doc = app.Create();
          TableFormatting normalTableFormatting =
               doc.CreateTableFormatting();

          //--- Get paragraph formatting from SimpleTable1 Style
          WordApplication app = new WordApplication();
          Document doc = app.Create();
          TableFormatting simpleTable1Formatting =
               doc.Styles[NamedStyle.BuiltIn.SimpleTable1];
        

          '--- Get NormalTable formatting from Document
          Dim app As New WordApplication()
          Dim doc As Document = app.Create()
          Dim normalTableFormatting As TableFormatting = _
               doc.CreateTableFormatting()

          '--- Get paragraph formatting from SimpleTable1 Style
          Dim app As New WordApplication()
          Dim doc As Document = app.Create()
          Dim simpleTable1Formatting As TableFormatting = _
               doc.Styles(NamedStyle.BuiltIn.SimpleTable1)
        

Name

Description

AutoWidth

CantSplit

DefaultShading

DefaultSpacing

Justification

LeftIndent

RepeatAsHeader

Name

Description

GetDefaultBorder(Border.Location)

GetDefaultPadding(TableCell.Location)

SetDefaultPadding(TableCell.Location, Int32)