Class OleObjectCollection
Contents
[
Hide
]OleObjectCollection class
Represents embedded OLE objects.
public class OleObjectCollection : CollectionBase<OleObject>
Properties
| Name | Description | 
|---|---|
| Capacity { get; set; } | |
| Count { get; } | |
| Item { get; } | Gets the OleObject element at the specified index. | 
| Item { get; set; } | 
Methods
| Name | Description | 
|---|---|
| Add(int, int, int, int, byte[]) | Adds an OleObject to the collection. | 
| Add(int, int, int, int, byte[], string) | Adds a linked OleObject to the collection. | 
| BinarySearch(OleObject) | |
| BinarySearch(OleObject, IComparer<OleObject>) | |
| BinarySearch(int, int, OleObject, IComparer<OleObject>) | |
| Clear() | Remove all embedded OLE objects. (2 methods) | 
| Contains(OleObject) | |
| CopyTo(OleObject[]) | |
| CopyTo(OleObject[], int) | |
| CopyTo(int, OleObject[], int, int) | |
| Exists(Predicate<OleObject>) | |
| Find(Predicate<OleObject>) | |
| FindAll(Predicate<OleObject>) | |
| FindIndex(Predicate<OleObject>) | |
| FindIndex(int, Predicate<OleObject>) | |
| FindIndex(int, int, Predicate<OleObject>) | |
| FindLast(Predicate<OleObject>) | |
| FindLastIndex(Predicate<OleObject>) | |
| FindLastIndex(int, Predicate<OleObject>) | |
| FindLastIndex(int, int, Predicate<OleObject>) | |
| GetEnumerator() | |
| IndexOf(OleObject) | |
| IndexOf(OleObject, int) | |
| IndexOf(OleObject, int, int) | |
| LastIndexOf(OleObject) | |
| LastIndexOf(OleObject, int) | |
| LastIndexOf(OleObject, int, int) | |
| RemoveAt(int) | Removes the element at the specified index. (2 methods) | 
Examples
using System;
using Aspose.Cells;
using Aspose.Cells.Drawing;
namespace AsposeCellsExamples
{
    public class DrawingClassOleObjectCollectionDemo
    {
        public static void Run()
        {
            // Create a new workbook
            Workbook workbook = new Workbook();
            Worksheet worksheet = workbook.Worksheets[0];
            // Add some OLE objects to the worksheet
            int oleObjectIndex1 = worksheet.OleObjects.Add(10, 10, 100, 100, new byte[0]);
            int oleObjectIndex2 = worksheet.OleObjects.Add(50, 50, 100, 100, new byte[0]);
            // Get the OleObjectCollection
            OleObjectCollection oleObjects = worksheet.OleObjects;
            // Display information about the OLE objects
            Console.WriteLine("OLE Objects Count: " + oleObjects.Count);
            for (int i = 0; i < oleObjects.Count; i++)
            {
                Console.WriteLine($"OLE Object {i + 1}:");
                Console.WriteLine($"- Position: ({oleObjects[i].UpperLeftRow}, {oleObjects[i].UpperLeftColumn})");
                Console.WriteLine($"- Size: {oleObjects[i].Width}x{oleObjects[i].Height}");
                Console.WriteLine($"- File: {oleObjects[i].FileFormatType}");
            }
            // Remove the first OLE object
            worksheet.OleObjects.RemoveAt(0);
            Console.WriteLine("\nAfter removing first OLE object:");
            Console.WriteLine("OLE Objects Count: " + oleObjects.Count);
            // Clear all OLE objects
            worksheet.OleObjects.Clear();
            Console.WriteLine("\nAfter clearing all OLE objects:");
            Console.WriteLine("OLE Objects Count: " + oleObjects.Count);
        }
    }
}
See Also
- class CollectionBase<T>
 - class OleObject
 - namespace Aspose.Cells.Drawing
 - assembly Aspose.Cells