Class ExternalConnectionCollection

ExternalConnectionCollection class

Specifies the ExternalConnection collection

public class ExternalConnectionCollection : CollectionBase<ExternalConnection>

Properties

NameDescription
Capacity { get; set; }
Count { get; }
Item { get; set; }Gets the ExternalConnection element at the specified index. (2 indexers)
Item { get; }Gets the ExternalConnection element with the specified name.

Methods

NameDescription
BinarySearch(ExternalConnection)
BinarySearch(ExternalConnection, IComparer<ExternalConnection>)
BinarySearch(int, int, ExternalConnection, IComparer<ExternalConnection>)
Clear()
Contains(ExternalConnection)
CopyTo(ExternalConnection[])
CopyTo(ExternalConnection[], int)
CopyTo(int, ExternalConnection[], int, int)
Exists(Predicate<ExternalConnection>)
Find(Predicate<ExternalConnection>)
FindAll(Predicate<ExternalConnection>)
FindIndex(Predicate<ExternalConnection>)
FindIndex(int, Predicate<ExternalConnection>)
FindIndex(int, int, Predicate<ExternalConnection>)
FindLast(Predicate<ExternalConnection>)
FindLastIndex(Predicate<ExternalConnection>)
FindLastIndex(int, Predicate<ExternalConnection>)
FindLastIndex(int, int, Predicate<ExternalConnection>)
GetEnumerator()
GetExternalConnectionById(int)Gets the ExternalConnection element with the specified id.
IndexOf(ExternalConnection)
IndexOf(ExternalConnection, int)
IndexOf(ExternalConnection, int, int)
LastIndexOf(ExternalConnection)
LastIndexOf(ExternalConnection, int)
LastIndexOf(ExternalConnection, int, int)
RemoveAt(int)

Examples

namespace AsposeCellsExamples
{
    using Aspose.Cells;
    using Aspose.Cells.ExternalConnections;
    using System;

    public class ExternalConnectionCollectionDemo
    {
        public static void ExternalConnectionCollectionExample()
        {
            // Load an existing workbook that contains external connections
            Workbook workbook = new Workbook("ExternalConnectionCollectionExample_original.xlsx");

            // Get the external connection collection from the workbook
            ExternalConnectionCollection dataConns = workbook.DataConnections;

            // Iterate through the external connections and print their IDs
            for (int i = 0; i < dataConns.Count; i++)
            {
                ExternalConnection dataConn = dataConns[i];
                // Get external connection id
                Console.WriteLine($"External Connection ID: {dataConn.ConnectionId}");
            }

            // Example of accessing a specific external connection by ID
            int specificConnId = 1; // Example ID
            ExternalConnection specificConn = dataConns.GetExternalConnectionById(specificConnId);
            if (specificConn != null)
            {
                Console.WriteLine($"Found External Connection with ID {specificConnId}");
                // You can access and modify properties of the specific connection here
                specificConn.Name = "Updated Connection Name";
            }

            // Save the workbook if any changes were made
            workbook.Save("ExternalConnectionCollectionExample.xlsx");
        }
    }
}

See Also