Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 4.0
Description

Excerpt

Represents a table in the Word document.

|Element.Type#Table].

The following sample demonstrates inserting a new table at the end of a document as well as finding the first table in a document.

{remarks}
{example}{code:csharp|title=C#}

          //--- Insert a table at the end of a new document with 3 rows and 5 columns
          WordApplication app = new WordApplication();
          Document doc = app.Create();
          Table table = doc.InsertTableAfter(3, 5);

          //--- Get the first table of an existing document
          WordApplication app = new WordApplication();
          Document doc = app.Open(@"C:\sample.doc");
          Table table = doc.GetElements(Element.Type.Table)[0];
        
{code}
{code:vb.net
|title=vb.net
}

          '--- Insert a table at the end of a new document with 3 rows and 5 columns
          Dim app As New WordApplication()
          Dim doc As Document = app.Create()
          Dim table As Table = doc.InsertTableAfter(3, 5)

          '--- Get the first table of an existing document
          Dim app As New WordApplication()
          Dim doc As Document = app.Open("C:\sample.doc")
          Dim table As Table = doc.GetElements(Element.Type.Table)(0)
        
Signature
C#C#
Wiki Markup
{description}
{excerpt}Represents a table in the Word document.{excerpt}
{signature:C#}
[DefaultMember("Item")]
 public sealed class Table : Element
Signature
{signature}{signature:vb.net
vb.net
}
<DefaultMember("Item")> _
	Public NotInheritable Class Table
		Inherits Element
Remarks
To create a new table, use
{signature}
{remarks}To create a new table, use [Element.InsertTableBefore()|Element.InsertTableBefore] or [InsertTableAfter()|Element.InsertTableAfter]. To get an existing table, use [Element.GetElements|Element.GetElements(Element.Type)] or [Element.Children|Element.Children] and check which elements are of type [Element.Type.Table
.

The following sample demonstrates inserting a new table at the end of a document as well as finding the first table in a document.

Example
Code Block
csharpcsharp
titleC#
Code Block
vb.nettitle
Properties

...

Name

...

Description

...

AbsolutePositioning

...

{code}

{example}
{properties}
||Name||Description||
|[AbsolutePositioning|Table.AbsolutePositioning]|{excerpt-include:Table.AbsolutePositioning

...

Formatting

|nopanel=true}|
|[Formatting|Table.Formatting]|{excerpt-include

...

:Table.Formatting

...

NumRows

|nopanel=true}|
|[NumRows|Table.NumRows]|{excerpt-include

...

:Table.NumRows

...

PreferredWidth

|nopanel=true}|
|[PreferredWidth|Table.PreferredWidth]|{excerpt-include

...

:Table.PreferredWidth

...

Style

|nopanel=true}|
|[Style|Table.Style]|{excerpt-include

...

:Table.Style

...

Indexers

...

Name

...

Description

|nopanel=true}|
{indexers}
||Name||Description||
|[Item(Int32, Int32)

...

|Table.Item(Int32, Int32)

...

]|{excerpt-include:Table.Item(Int32, Int32)

...

|nopanel

...

Methods

...

Name

...

Description

=true}|
{methods}
||Name||Description||
|[AddColumns(Int32)

...

|Table.AddColumns(Int32)

...

]|{excerpt-include:Table.AddColumns(Int32)

...

|nopanel

...

=true}|
|[AddRows(Int32)

...

|Table.AddRows(Int32)

...

]|{excerpt-include:Table.AddRows(Int32)

...

|nopanel

...

=true}|
|[CreateBookmarkOnRow(Int32, String)

...

|Table.CreateBookmarkOnRow(Int32, String)

...

]|{excerpt-include:Table.CreateBookmarkOnRow(Int32, String)

...

|nopanel

...

=true}|
|[DeleteColumns(Int32, Int32)

...

|Table.DeleteColumns(Int32, Int32)]|{excerpt-include:Table.DeleteColumns(Int32,

...

 
|[DeleteRows(Int32, Int32)

...

|Table.DeleteRows(Int32, Int32)

...

]|{excerpt-include:Table.DeleteRows(Int32, Int32)

...

|nopanel

...

=true}|
|[GetNumColumns(Int32)

...

|Table.GetNumColumns(Int32)

...

]|{excerpt-include:Table.GetNumColumns(Int32)

...

|nopanel

...

=true}|
|[GetPreferredColumnWidth(Int32)

...

|Table.GetPreferredColumnWidth(Int32)

...

]|{excerpt-include:Table.GetPreferredColumnWidth(Int32)

...

|nopanel

...

=true}|
|[GetPreferredColumnWidthUnits(Int32)

...

|Table.GetPreferredColumnWidthUnits(Int32)

...

]|{excerpt-include:Table.GetPreferredColumnWidthUnits(Int32)

...

|nopanel

...

=true}|
|[GetPreferredWidth(out Units)

...

|Table.GetPreferredWidth(out Units)

...

]|{excerpt-include:Table.GetPreferredWidth(out Units)

...

|nopanel

...

=true}|
|[GetRowHeight(Int32)

...

|Table.GetRowHeight(Int32)

...

]|{excerpt-include:Table.GetRowHeight(Int32)

...

|nopanel

...

=true}|
|[GetRowHeightExact(Int32)

...

|Table.GetRowHeightExact(Int32)

...

]|{excerpt-include:Table.GetRowHeightExact(Int32)

...

|nopanel

...

=true}|
|[ImportDataRow(Object())

...

|Table.ImportDataRow(Object())

...

]|{excerpt-include:Table.ImportDataRow(Object())

...

|nopanel

...

=true}|
|[InsertColumns(Int32, Int32)

...

|Table.InsertColumns(Int32, Int32)

...

]|{excerpt-include:Table.InsertColumns(Int32, Int32)

...

|nopanel

...

=true}|
|[InsertRows(Int32, Int32)

...

|Table.InsertRows(Int32, Int32)

...

]|{excerpt-include:Table.InsertRows(Int32, Int32)

...

|nopanel

...

=true}|
|[MergeCells(Int32, Int32, Int32, Int32)

...

|Table.MergeCells(Int32, Int32, Int32, Int32)

...

]|{excerpt-include:Table.MergeCells(Int32, Int32, Int32, Int32)

...

|nopanel

...

=true}|
|[SetPreferredColumnWidth(Int32, Int32)

...

|Table.SetPreferredColumnWidth(Int32, Int32)

...

]|{excerpt-include:Table.SetPreferredColumnWidth(Int32, Int32)

...

|nopanel

...

=true}|
|[SetPreferredColumnWidthUnits(Int32, TableCell.WidthUnits)

...

|Table.SetPreferredColumnWidthUnits(Int32, TableCell.WidthUnits)

...

]|{excerpt-include:Table.SetPreferredColumnWidthUnits(Int32, TableCell.WidthUnits)

...

|nopanel

...

=true}|
|[SetPreferredWidth(Double, Units)

...

|Table.SetPreferredWidth(Double, Units)

...

]|{excerpt-include:Table.SetPreferredWidth(Double, Units)

...

|nopanel

...

=true}|
|[SetRowHeight(Int32, Int32)

...

|Table.SetRowHeight(Int32, Int32)

...

]|{excerpt-include:Table.SetRowHeight(Int32, Int32)

...

|nopanel

...

=true}|
|[SetRowHeightExact(Int32, Boolean)

...

|Table.SetRowHeightExact(Int32, Boolean)

...

]|{excerpt-include:Table.SetRowHeightExact(Int32, Boolean)

...

|nopanel

...

=true}|