Class WTableCollection
Represents a collection of IWTable objects.
Inherited Members
Namespace: Syncfusion.DocIO.DLS
Assembly: Syncfusion.DocIO.Portable.dll
Syntax
public class WTableCollection : EntitySubsetCollection, IWTableCollection, IEntityCollectionBase, ICollectionBase, IEnumerable
Examples
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load a template document
WordDocument document = new WordDocument("Template.docx");
//Get the tables collection
WTableCollection tablecollection = document.Sections[0].Tables as WTableCollection;
//Create new table
WTable table = new WTable(document);
table.ResetCells(2,2);
//Add table to the collection
tablecollection.Add(table);
//Get the index of the added table
int index = tablecollection.IndexOf(table);
//Insert another table at next index
table = new WTable(document);
table.ResetCells(3, 3);
tablecollection.Insert(index + 1, table);
//Remove the table at index 0
tablecollection.RemoveAt(0);
//Save and close the document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load a template document
Dim document As New WordDocument("Template.docx")
'Get the tables collection
Dim tablecollection As WTableCollection = TryCast(document.Sections(0).Tables, WTableCollection)
'Create new table
Dim table As New WTable(document)
table.ResetCells(2, 2)
'Add table to the collection
tablecollection.Add(table)
'Get the index of the added table
Dim index As Integer = tablecollection.IndexOf(table)
'Insert another table at next index
table = New WTable(document)
table.ResetCells(3, 3)
tablecollection.Insert(index + 1, table)
'Remove the table at index 0
tablecollection.RemoveAt(0)
'Save and close the document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
End Sub
Constructors
WTableCollection(BodyItemCollection)
Initializes a new instance of the WTableCollection class with the specified BodyItemCollection instance.
Declaration
public WTableCollection(BodyItemCollection bodyItems)
Parameters
Type | Name | Description |
---|---|---|
BodyItemCollection | bodyItems | The collection of body items. |
Properties
Item[Int32]
Gets the IWTable at the specified index.
Declaration
public IWTable this[int index] { get; }
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | The zero-based index to get the table. |
Property Value
Type | Description |
---|---|
IWTable | The IWTable at the specified index. |
Exceptions
Type | Condition |
---|---|
System.ArgumentOutOfRangeException | The index is not valid in the WTableCollection. |
Methods
Add(IWTable)
Adds the specified table to the end of text body.
Declaration
public int Add(IWTable table)
Parameters
Type | Name | Description |
---|---|---|
IWTable | table | The IWTable to be added. |
Returns
Type | Description |
---|---|
System.Int32 | The zero-based index of the table. |
Contains(IWTable)
Determines whether the IWTableCollection contains the specified table.
Declaration
public bool Contains(IWTable table)
Parameters
Type | Name | Description |
---|---|---|
IWTable | table | The IWTable object to be found. |
Returns
Type | Description |
---|---|
System.Boolean | True if table is found, otherwise |
IndexOf(IWTable)
Returns the index of the specified table in the collection.
Declaration
public int IndexOf(IWTable table)
Parameters
Type | Name | Description |
---|---|---|
IWTable | table | The IWTable to which the index to be found. |
Returns
Type | Description |
---|---|
System.Int32 | The zero-based index of the table. |
Insert(Int32, IWTable)
Inserts the specified table into collection at the specified index.
Declaration
public int Insert(int index, IWTable table)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | The zero-based index for the table to insert. |
IWTable | table | The IWTable to be inserted. |
Returns
Type | Description |
---|---|
System.Int32 | The zero-based index of the item inserted. |
Exceptions
Type | Condition |
---|---|
System.ArgumentOutOfRangeException | The index is not valid within the IWTableCollection. |
Remove(IWTable)
Removes the specified table from the collection.
Declaration
public void Remove(IWTable table)
Parameters
Type | Name | Description |
---|---|---|
IWTable | table | The IWTable to be removed from the collection. |
RemoveAt(Int32)
Removes the table at the specified index from the collection.
Declaration
public void RemoveAt(int index)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | The zero-based index of the table to be removed. |
Exceptions
Type | Condition |
---|---|
System.ArgumentOutOfRangeException | The index is not valid within the IWTableCollection |