menu

WinUI

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Interface IOleObjects - WinUI API Reference | Syncfusion

    Show / Hide Table of Contents

    Interface IOleObjects

    Represents the Ole objects shape collections.

    Namespace: Syncfusion.XlsIO
    Assembly: Syncfusion.XlsIO.NET.dll
    Syntax
    public interface IOleObjects : IList<IOleObject>, ICollection<IOleObject>, IEnumerable<IOleObject>, IEnumerable

    Methods

    Add(Stream, Image, OleObjectType)

    Adds the OLE object to the collection with embedded content

    Declaration
    IOleObject Add(Stream oleStream, Image image, OleObjectType type)
    Parameters
    Type Name Description
    System.IO.Stream oleStream

    The System.IO.Stream represents the OLE file stream.

    Image image

    The instance for the OLE image.

    OleObjectType type

    Type of OLE object.

    Returns
    Type Description
    IOleObject

    Newly created OLE object.

    Remarks

    This method is particularly used to embed the ole object for all object types except package type. This method is only supported in UWP, ASP.NET Core and Xamarin.

    Examples

    The following code illustrates how to add an IListObject to the IListObjects collection.

    using Syncfusion.XlsIO;
    using System.Drawing;
    using System.IO;
    
    class Program
    {
        static void Main()
        {
            using (ExcelEngine excelEngine = new ExcelEngine())
            {
                //Create worksheet
                IApplication application = excelEngine.Excel;
                application.DefaultVersion = ExcelVersion.Excel2013;
                IWorkbook workbook = application.Workbooks.Create(1);
                IWorksheet worksheet = workbook.Worksheets[0];
    
                //Create file stream
                Stream stream = new FileStream("Shapes.xlsx", FileMode.Open);
    
                //Create image stream
                Image image = Image.FromFile("image.png");
    
                //Add ole object
                IOleObject oleObject = worksheet.OleObjects.Add(stream, image, OleObjectType.ExcelWorksheet);
    
                //Save and dispose
                workbook.SaveAs("OLEObjects.xlsx");
                workbook.Close();
            }
        }
    }

    Add(Stream, Image, String)

    Adds the OLE object to the collection with embedded content

    Declaration
    IOleObject Add(Stream oleStream, Image image, string fileExtension)
    Parameters
    Type Name Description
    System.IO.Stream oleStream

    The System.IO.Stream represents the OLE file stream.

    Image image

    The instance for the OLE image.

    System.String fileExtension

    The string that specifies the file extension.

    Returns
    Type Description
    IOleObject

    Newly created OLE object.

    Remarks

    This method is particularly used to embed the ole object for object type package. This method is only supported in UWP, ASP.NET Core and Xamarin.

    Examples

    The following code illustrates how to add an IListObject to the IListObjects collection.

    using Syncfusion.XlsIO;
    using System.Drawing;
    using System.IO;
    
    class Program
    {
        static void Main()
        {
            using (ExcelEngine excelEngine = new ExcelEngine())
            {
                //Create worksheet
                IApplication application = excelEngine.Excel;
                application.DefaultVersion = ExcelVersion.Excel2013;
                IWorkbook workbook = application.Workbooks.Create(1);
                IWorksheet worksheet = workbook.Worksheets[0];
    
                //Create file stream
                Stream stream = new FileStream("Shapes.xlsx", FileMode.Open);
    
                //Create image stream
                Image image = Image.FromFile("image.png");
    
                //Add ole object
                IOleObject oleObject = worksheet.OleObjects.Add(stream, image, "xlsx");
    
                //Save and dispose
                workbook.SaveAs("OLEObjects.xlsx");
                workbook.Close();
            }
        }
    }

    AddLink(String, Image)

    Adds the OLE object to the collection with linking the content

    Declaration
    IOleObject AddLink(string filePath, Image image)
    Parameters
    Type Name Description
    System.String filePath

    The string that specifies the valid file path of the linked file.

    Image image

    The instance for the OLE image.

    Returns
    Type Description
    IOleObject

    Newly created OLE object.

    Remarks

    This method particularly used to add the ole objects. This method is only supported in UWP, ASP.NET Core and Xamarin.

    Examples

    The following code illustrates how to add an IListObject to the IListObjects collection.

    using Syncfusion.XlsIO;
    using System.Drawing;
    
    class Program
    {
        static void Main()
        {
            using (ExcelEngine excelEngine = new ExcelEngine())
            {
                //Create worksheet
                IApplication application = excelEngine.Excel;
                application.DefaultVersion = ExcelVersion.Excel2013;
                IWorkbook workbook = application.Workbooks.Create(1);
                IWorksheet worksheet = workbook.Worksheets[0];
    
                //Create image stream
                Image image = Image.FromFile("image.png");
    
                //Add ole object
                IOleObject oleObject = worksheet.OleObjects.AddLink("Shapes.xlsx", image);
    
                //Save and dispose
                workbook.SaveAs("OLEObjects.xlsx");
                workbook.Close();
            }
        }
    }
    Back to top Generated by DocFX
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved