Skip to end of metadata
Go to start of metadata
To add a table to a section of your document, use one of the following methods. All of the methods insert a table at a specified point in an Element. An Element object represents an editable region in a document, such as a section or paragraph. The document itself is an Element.
  • Inserts an empty table, with a specified number of rows and columns, at the end of the element.

  • Inserts an empty table, with a specified number of rows and columns, at the end of the element. This method applies a set of table formatting properties (contained in a TableFormatting object) to the new table.

  • Inserts an empty table, with a specified number of rows and columns, at the beginning of the element.

  • Inserts an empty table, with a specified number of rows and columns, at the beginning of the element. This method applies a set of table formatting properties (contained in a TableFormatting object) to the new table.

  • Inserts an empty table at a specified position within an Element. A Position object represents a cursor.

Before adding a table to your file, you must create a content region in which to insert the table. Each editable region in a Word file is represented by an Element object, or an object that extends Element, such as a Document object.

To insert an empty table, use one of the methods listed at the beginning of this section, for example:

To enter text in the table, first return one or more TableCellobjects:

To add text to a table cell, call one of the Element class's InsertTextAfter or InsertTextBefore methods.

You can access existing tables through the Element.Elements property.

Table Formatting

To apply a font to text in a table cell, create a Font object and pass it to TableCell.InsertTextAfter or TableCell.InsertTextBefore, as demonstrated above.

Other paragraph formatting can be applied through the Tableobject or the TableFormatting object. To create a TableFormatting object, call Document.CreateTableFormatting:

Next, set TableFormatting properties.

To assign the TableFormatting object that you created to a table, pass it to Element.InsertTableAfter orElement.InsertTableBefore when you create a new table.

  • No labels