Class ListObjectCollection
Represents collection of table in the worksheet.
Inheritance
System.Object
ListObjectCollection
Implements
System.Collections.IList
System.Collections.ICollection
System.Collections.Generic.IReadOnlyCollection<
IListObject>
System.Collections.IEnumerable
Inherited Members
System.Collections.Generic.List<Syncfusion.XlsIO.IListObject>.System.Collections.IList.get_Item(System.Int32)
System.Collections.Generic.List<Syncfusion.XlsIO.IListObject>.System.Collections.IList.set_Item(System.Int32, System.Object)
System.Collections.Generic.List<Syncfusion.XlsIO.IListObject>.Add(Syncfusion.XlsIO.IListObject)
System.Collections.Generic.List<Syncfusion.XlsIO.IListObject>.System.Collections.IList.Add(System.Object)
System.Collections.Generic.List<Syncfusion.XlsIO.IListObject>.AddRange(System.Collections.Generic.IEnumerable<Syncfusion.XlsIO.IListObject>)
System.Collections.Generic.List<Syncfusion.XlsIO.IListObject>.AsReadOnly()
System.Collections.Generic.List<Syncfusion.XlsIO.IListObject>.BinarySearch(System.Int32, System.Int32, Syncfusion.XlsIO.IListObject, System.Collections.Generic.IComparer<Syncfusion.XlsIO.IListObject>)
System.Collections.Generic.List<Syncfusion.XlsIO.IListObject>.BinarySearch(Syncfusion.XlsIO.IListObject)
System.Collections.Generic.List<Syncfusion.XlsIO.IListObject>.BinarySearch(Syncfusion.XlsIO.IListObject, System.Collections.Generic.IComparer<Syncfusion.XlsIO.IListObject>)
System.Collections.Generic.List<Syncfusion.XlsIO.IListObject>.Clear()
System.Collections.Generic.List<Syncfusion.XlsIO.IListObject>.Contains(Syncfusion.XlsIO.IListObject)
System.Collections.Generic.List<Syncfusion.XlsIO.IListObject>.System.Collections.IList.Contains(System.Object)
System.Collections.Generic.List<Syncfusion.XlsIO.IListObject>.ConvertAll<TOutput>(System.Converter<Syncfusion.XlsIO.IListObject, TOutput>)
System.Collections.Generic.List<Syncfusion.XlsIO.IListObject>.CopyTo(Syncfusion.XlsIO.IListObject[])
System.Collections.Generic.List<Syncfusion.XlsIO.IListObject>.System.Collections.ICollection.CopyTo(System.Array, System.Int32)
System.Collections.Generic.List<Syncfusion.XlsIO.IListObject>.CopyTo(System.Int32, Syncfusion.XlsIO.IListObject[], System.Int32, System.Int32)
System.Collections.Generic.List<Syncfusion.XlsIO.IListObject>.CopyTo(Syncfusion.XlsIO.IListObject[], System.Int32)
System.Collections.Generic.List<Syncfusion.XlsIO.IListObject>.Exists(System.Predicate<Syncfusion.XlsIO.IListObject>)
System.Collections.Generic.List<Syncfusion.XlsIO.IListObject>.Find(System.Predicate<Syncfusion.XlsIO.IListObject>)
System.Collections.Generic.List<Syncfusion.XlsIO.IListObject>.FindAll(System.Predicate<Syncfusion.XlsIO.IListObject>)
System.Collections.Generic.List<Syncfusion.XlsIO.IListObject>.FindIndex(System.Predicate<Syncfusion.XlsIO.IListObject>)
System.Collections.Generic.List<Syncfusion.XlsIO.IListObject>.FindIndex(System.Int32, System.Predicate<Syncfusion.XlsIO.IListObject>)
System.Collections.Generic.List<Syncfusion.XlsIO.IListObject>.FindIndex(System.Int32, System.Int32, System.Predicate<Syncfusion.XlsIO.IListObject>)
System.Collections.Generic.List<Syncfusion.XlsIO.IListObject>.FindLast(System.Predicate<Syncfusion.XlsIO.IListObject>)
System.Collections.Generic.List<Syncfusion.XlsIO.IListObject>.FindLastIndex(System.Predicate<Syncfusion.XlsIO.IListObject>)
System.Collections.Generic.List<Syncfusion.XlsIO.IListObject>.FindLastIndex(System.Int32, System.Predicate<Syncfusion.XlsIO.IListObject>)
System.Collections.Generic.List<Syncfusion.XlsIO.IListObject>.FindLastIndex(System.Int32, System.Int32, System.Predicate<Syncfusion.XlsIO.IListObject>)
System.Collections.Generic.List<Syncfusion.XlsIO.IListObject>.ForEach(System.Action<Syncfusion.XlsIO.IListObject>)
System.Collections.Generic.List<Syncfusion.XlsIO.IListObject>.GetEnumerator()
System.Collections.Generic.List<Syncfusion.XlsIO.IListObject>.System.Collections.Generic.IEnumerable<Syncfusion.XlsIO.IListObject>.GetEnumerator()
System.Collections.Generic.List<Syncfusion.XlsIO.IListObject>.System.Collections.IEnumerable.GetEnumerator()
System.Collections.Generic.List<Syncfusion.XlsIO.IListObject>.GetRange(System.Int32, System.Int32)
System.Collections.Generic.List<Syncfusion.XlsIO.IListObject>.IndexOf(Syncfusion.XlsIO.IListObject)
System.Collections.Generic.List<Syncfusion.XlsIO.IListObject>.System.Collections.IList.IndexOf(System.Object)
System.Collections.Generic.List<Syncfusion.XlsIO.IListObject>.IndexOf(Syncfusion.XlsIO.IListObject, System.Int32)
System.Collections.Generic.List<Syncfusion.XlsIO.IListObject>.IndexOf(Syncfusion.XlsIO.IListObject, System.Int32, System.Int32)
System.Collections.Generic.List<Syncfusion.XlsIO.IListObject>.Insert(System.Int32, Syncfusion.XlsIO.IListObject)
System.Collections.Generic.List<Syncfusion.XlsIO.IListObject>.System.Collections.IList.Insert(System.Int32, System.Object)
System.Collections.Generic.List<Syncfusion.XlsIO.IListObject>.InsertRange(System.Int32, System.Collections.Generic.IEnumerable<Syncfusion.XlsIO.IListObject>)
System.Collections.Generic.List<Syncfusion.XlsIO.IListObject>.LastIndexOf(Syncfusion.XlsIO.IListObject)
System.Collections.Generic.List<Syncfusion.XlsIO.IListObject>.LastIndexOf(Syncfusion.XlsIO.IListObject, System.Int32)
System.Collections.Generic.List<Syncfusion.XlsIO.IListObject>.LastIndexOf(Syncfusion.XlsIO.IListObject, System.Int32, System.Int32)
System.Collections.Generic.List<Syncfusion.XlsIO.IListObject>.System.Collections.IList.Remove(System.Object)
System.Collections.Generic.List<Syncfusion.XlsIO.IListObject>.RemoveAll(System.Predicate<Syncfusion.XlsIO.IListObject>)
System.Collections.Generic.List<Syncfusion.XlsIO.IListObject>.RemoveRange(System.Int32, System.Int32)
System.Collections.Generic.List<Syncfusion.XlsIO.IListObject>.Reverse()
System.Collections.Generic.List<Syncfusion.XlsIO.IListObject>.Reverse(System.Int32, System.Int32)
System.Collections.Generic.List<Syncfusion.XlsIO.IListObject>.Sort()
System.Collections.Generic.List<Syncfusion.XlsIO.IListObject>.Sort(System.Collections.Generic.IComparer<Syncfusion.XlsIO.IListObject>)
System.Collections.Generic.List<Syncfusion.XlsIO.IListObject>.Sort(System.Int32, System.Int32, System.Collections.Generic.IComparer<Syncfusion.XlsIO.IListObject>)
System.Collections.Generic.List<Syncfusion.XlsIO.IListObject>.Sort(System.Comparison<Syncfusion.XlsIO.IListObject>)
System.Collections.Generic.List<Syncfusion.XlsIO.IListObject>.ToArray()
System.Collections.Generic.List<Syncfusion.XlsIO.IListObject>.TrimExcess()
System.Collections.Generic.List<Syncfusion.XlsIO.IListObject>.TrueForAll(System.Predicate<Syncfusion.XlsIO.IListObject>)
System.Collections.Generic.List<Syncfusion.XlsIO.IListObject>.Capacity
System.Collections.Generic.List<Syncfusion.XlsIO.IListObject>.Count
System.Collections.Generic.List<Syncfusion.XlsIO.IListObject>.System.Collections.IList.IsFixedSize
System.Collections.Generic.List<Syncfusion.XlsIO.IListObject>.System.Collections.Generic.ICollection<Syncfusion.XlsIO.IListObject>.IsReadOnly
System.Collections.Generic.List<Syncfusion.XlsIO.IListObject>.System.Collections.IList.IsReadOnly
System.Collections.Generic.List<Syncfusion.XlsIO.IListObject>.System.Collections.ICollection.IsSynchronized
System.Collections.Generic.List<Syncfusion.XlsIO.IListObject>.System.Collections.ICollection.SyncRoot
System.Collections.Generic.List<Syncfusion.XlsIO.IListObject>.Item[System.Int32]
System.Collections.Generic.List<Syncfusion.XlsIO.IListObject>.System.Collections.IList.Item[System.Int32]
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Assembly: Syncfusion.XlsIO.Base.dll
Syntax
public class ListObjectCollection : List<IListObject>, IList, ICollection, IReadOnlyList<IListObject>, IReadOnlyCollection<IListObject>, IListObjects, IList<IListObject>, ICollection<IListObject>, IEnumerable<IListObject>, IEnumerable
Constructors
ListObjectCollection(WorksheetImpl)
Initializes a new instance of ListObjectCollection class.
Declaration
public ListObjectCollection(WorksheetImpl sheet)
Parameters
Type |
Name |
Description |
WorksheetImpl |
sheet |
Sheet to which this collection belongs to.
|
Properties
Item[String]
Returns table object with the given name. Read-only.
Declaration
public IListObject this[string name] { get; }
Parameters
Type |
Name |
Description |
System.String |
name |
Name of the table.
|
Property Value
Type |
Description |
IListObject |
Table object with the given name.
|
Methods
AddDefineName(IListObject)
Adds the table name to the defined names in the workbook.
Declaration
public void AddDefineName(IListObject list)
Parameters
AddEx(ExcelListObjectSourceType, IConnection, IRange)
Creates a query table with specified connection and its source type. Adds it to the IListObjects collection.
Declaration
public IListObject AddEx(ExcelListObjectSourceType type, IConnection connection, IRange Destinaion)
Parameters
Returns
Type |
Description |
IListObject |
Returns a List object with the specified connections.
|
Examples
Following code illustrates how to create a table with an external connections.
ExcelEngine excelEngine = new ExcelEngine();
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet worksheet = workbook.Worksheets[0];
// Database path
string dataPath = Path.GetFullPath(@"c:\company\DB\TestDB.mdb");
// Connection string for DataSource
string ConnectionString = "OLEDB;Provider=Microsoft.JET.OLEDB.4.0;Password=\"\";User ID=Admin;Data Source=" + dataPath;
// Adding a connection to the workbook
IConnection Connection = workbook.Connections.Add("Connection1", "Sample connection with MsAccess", ConnectionString, "", ExcelCommandType.Sql);
// Adding a QueryTable to sheet object
worksheet.ListObjects.AddEx(ExcelListObjectSourceType.SrcQuery, Connection, worksheet.Range["A1"]);
// Command Text for the Connection
worksheet.ListObjects[0].QueryTable.CommandText = "Select * from tblTest";
// The Query performs Asynchronous action
worksheet.ListObjects[0].QueryTable.BackgroundQuery = true;
// The Query Table is refreshed when the Workbook is opened
worksheet.ListObjects[0].QueryTable.RefreshOnFileOpen = true;
// Represents the connection description
Connection.Description = "Sample Connection";
// Import data to the sheet from the database
worksheet.ListObjects[0].Refresh();
// Auto-fits the columns
worksheet.UsedRange.AutofitColumns();
string fileName = "Output.xlsx";
workbook.SaveAs(fileName);
workbook.Close();
excelEngine.Dispose();
Create(String, IRange)
Creates a table with specified name and its data range. Adds it to the IListObjects collection.
Declaration
public IListObject Create(string name, IRange range)
Parameters
Type |
Name |
Description |
System.String |
name |
Represents the name of the table.
|
IRange |
range |
Represents the data range of the table.
|
Returns
Type |
Description |
IListObject |
Returns a List object with the specified name and range.
|
Examples
Following code illustrates how to create a table.
ExcelEngine excelEngine = new ExcelEngine();
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Open("Sample.xlsx", ExcelOpenType.Automatic);
IWorksheet worksheet = workbook.Worksheets[0];
// Create Table with data in the given range
IListObject table = worksheet.ListObjects.Create("Table1", worksheet["A1:C8"]);
string fileName = "Output.xlsx";
workbook.SaveAs(fileName);
workbook.Close();
excelEngine.Dispose();
Remove(IListObject)
Removes a table from the worksheet.
Declaration
public bool Remove(IListObject listObject)
Parameters
Type |
Name |
Description |
IListObject |
listObject |
ListObject to be removed
|
Returns
Type |
Description |
System.Boolean |
true if table is successfully removed; otherwise, false.
|
Examples
Following code illustrates how to remove a table from the worksheet.
using (ExcelEngine excelEngine = new ExcelEngine())
{
IApplication application = excelEngine.Excel;
IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
IWorksheet worksheet = workbook.Worksheets["Database"];
IListObjects listObjects = worksheet.ListObjects;
IListObject table = listObjects[0];
listObjects.Remove(table);
workbook.SaveAs("output.xlsx");
}
RemoveAt(Int32)
Removes a table from the worksheet at the specified index.
Declaration
public void RemoveAt(int index)
Parameters
Type |
Name |
Description |
System.Int32 |
index |
Index of the ListObject to be removed
|
Examples
Following code illustrates how to remove a table from the worksheet from using specified index.
using (ExcelEngine excelEngine = new ExcelEngine())
{
IApplication application = excelEngine.Excel;
IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
IWorksheet worksheet = workbook.Worksheets["Database"];
IListObjects listObjects = worksheet.ListObjects;
listObjects.RemoveAt(0);
workbook.SaveAs("output.xlsx");
}
Implements
System.Collections.IList
System.Collections.ICollection
System.Collections.Generic.IReadOnlyList<T>
System.Collections.Generic.IReadOnlyCollection<T>
System.Collections.Generic.IList<T>
System.Collections.Generic.ICollection<T>
System.Collections.Generic.IEnumerable<T>
System.Collections.IEnumerable