alexa
menu

MAUI

  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Search Results for

    Show / Hide Table of Contents

    Interface IPictures

    A collection of cell comments. Each comment is represented by a Comment object.

    Inherited Members
    IEnumerable.GetEnumerator()
    IParentApplication.Application
    IParentApplication.Parent
    Namespace: Syncfusion.XlsIO
    Assembly: Syncfusion.XlsIO.NET.dll
    Syntax
    public interface IPictures : IParentApplication, IEnumerable

    Properties

    Count

    Returns the number of IPictureShape objects in the IPictures collection. Read-only Long.

    Declaration
    int Count { get; }
    Property Value
    Type
    int
    Examples

    The following code illustrates how to access Count property.

    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];
    
        //Add pictures
        worksheet.Pictures.AddPicture("image.png");
        worksheet.Pictures.AddPicture("image.png");
    
        //Get count
        Console.Write(worksheet.Pictures.Count);
    
        //Save and dispose
        workbook.SaveAs("Pictures.xlsx");
        workbook.Close();
        Console.ReadKey();
    }

    this[int]

    Returns a single IPictureShape object from the IPictures collection.

    Declaration
    IPictureShape this[int Index] { get; }
    Parameters
    Type Name Description
    int Index
    Property Value
    Type
    IPictureShape
    Remarks

    To know more about changing the dimensions of the IPictureShape added to IWorksheet refer Positioning and Re-Sizing Pictures.

    Examples

    The following code illustrates how to access an IPictureShape object in the IPictures collection.

    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];
    
        //Add picture
        worksheet.Pictures.AddPicture("image.png");
    
        //Set picture
        IPictureShape picture = worksheet.Pictures[0];
    
        //Set dimension
        picture.Left = 3;
        picture.Top = 3;
        picture.Height = 50;
        picture.Width = 50;
    
        //Save and dispose
        workbook.SaveAs("Pictures.xlsx");
        workbook.Close();
    }

    this[string]

    Gets single IPictureShape from the IPictures collection.

    Declaration
    IPictureShape this[string name] { get; }
    Parameters
    Type Name Description
    string name

    Name of the item to get.

    Property Value
    Type Description
    IPictureShape

    Single item from the collection.

    Examples

    The following code illustrates how to access a IPictureShape object from the IPictures collection.

    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];
    
        //Add picture
        worksheet.Pictures.AddPicture("image.png");
    
        //Set picture
        IPictureShape picture = worksheet.Pictures["image"];
    
        //Set dimension
        picture.Left = 3;
        picture.Top = 3;
        picture.Height = 50;
        picture.Width = 50;
    
        //Save and dispose
        workbook.SaveAs("OLEObjects.xlsx");
        workbook.Close();
    }

    Methods

    AddPicture(int, int, Image)

    Adds IPictureShape to the IPictures collection.

    Declaration
    IPictureShape AddPicture(int topRow, int leftColumn, Image image)
    Parameters
    Type Name Description
    int topRow

    Top row of a new picture.

    int leftColumn

    Left column.

    Image image

    Image.

    Returns
    Type Description
    IPictureShape

    Added picture.

    Examples

    The following code illustrates how to add a IPictureShape to the IPictures collection.

    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];
    
        //Get image
        System.Drawing.Image image = System.Drawing.Image.FromFile("image.png");
    
        //Add image
        IPictureShape picture = worksheet.Pictures.AddPicture(4, 5, image);
    
        //Save and dispose
        workbook.SaveAs("Shapes.xlsx");
        workbook.Close();
    }

    AddPicture(int, int, Image, ExcelImageFormat)

    Adds IPictureShape to the IPictures collection.

    Declaration
    IPictureShape AddPicture(int topRow, int leftColumn, Image image, ExcelImageFormat imageFormat)
    Parameters
    Type Name Description
    int topRow

    Top row of a new picture.

    int leftColumn

    Left column.

    Image image

    Image to add.

    ExcelImageFormat imageFormat

    Image format to use for picture storing.

    Returns
    Type Description
    IPictureShape

    Added picture.

    Examples

    The following code illustrates how to add a IPictureShape to the IPictures collection.

    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];
    
        //Get image
        System.Drawing.Image image = System.Drawing.Image.FromFile("image.png");
    
        //Add image
        IPictureShape picture = worksheet.Pictures.AddPicture(4, 5, image, ExcelImageFormat.Jpeg);
    
        //Save and dispose
        workbook.SaveAs("Shapes.xlsx");
        workbook.Close();
    }

    AddPicture(int, int, Image, int, int)

    Adds IPictureShape to the IPictures collection.

    Declaration
    IPictureShape AddPicture(int topRow, int leftColumn, Image image, int scaleWidth, int scaleHeight)
    Parameters
    Type Name Description
    int topRow

    Top row of a new picture.

    int leftColumn

    Left column.

    Image image

    Image.

    int scaleWidth

    Width scale in percents.

    int scaleHeight

    Height scale in percents.

    Returns
    Type Description
    IPictureShape

    Added picture.

    Examples

    The following code illustrates how to add a IPictureShape to the IPictures collection.

    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];
    
        //Get image
        System.Drawing.Image image = System.Drawing.Image.FromFile("image.png");
    
        //Add image
        IPictureShape picture = worksheet.Pictures.AddPicture(1, 1, image, 50, 50);
    
        //Save and dispose
        workbook.SaveAs("Shapes.xlsx");
        workbook.Close();
    }

    AddPicture(int, int, Image, int, int, ExcelImageFormat)

    Adds IPictureShape to the IPictures collection.

    Declaration
    IPictureShape AddPicture(int topRow, int leftColumn, Image image, int scaleWidth, int scaleHeight, ExcelImageFormat imageFormat)
    Parameters
    Type Name Description
    int topRow

    Top row of a new picture.

    int leftColumn

    Left column.

    Image image

    Image.

    int scaleWidth

    Width scale in percents.

    int scaleHeight

    Height scale in percents.

    ExcelImageFormat imageFormat

    Image format to use for picture storing.

    Returns
    Type Description
    IPictureShape

    Added picture.

    Examples

    The following code illustrates how to add a IPictureShape to the IPictures collection.

    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];
    
        //Get image
        System.Drawing.Image image = System.Drawing.Image.FromFile("image.png");
    
        //Add image
        IPictureShape picture = worksheet.Pictures.AddPicture(1, 1, image, 50, 50, ExcelImageFormat.Jpeg);
    
        //Save and dispose
        workbook.SaveAs("Shapes.xlsx");
        workbook.Close();
    }

    AddPicture(int, int, Stream)

    Adds IPictureShape to the IPictures collection.

    Declaration
    IPictureShape AddPicture(int topRow, int leftColumn, Stream stream)
    Parameters
    Type Name Description
    int topRow

    Top row of a new picture.

    int leftColumn

    Left column.

    Stream stream

    Stream with the picture.

    Returns
    Type Description
    IPictureShape

    Added picture.

    Examples

    The following code illustrates how to add a IPictureShape to the IPictures collection.

    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
        Stream stream = new FileStream("image.png", FileMode.Open);
    
        //Add image
        IPictureShape picture = worksheet.Pictures.AddPicture(1, 1, stream);
    
        //Save and dispose
        workbook.SaveAs("Shapes.xlsx");
        workbook.Close();
    }

    AddPicture(int, int, Stream, ExcelImageFormat)

    Adds IPictureShape to the IPictures collection.

    Declaration
    IPictureShape AddPicture(int topRow, int leftColumn, Stream stream, ExcelImageFormat imageFormat)
    Parameters
    Type Name Description
    int topRow

    Top row of a new picture.

    int leftColumn

    Left column.

    Stream stream

    Stream with the picture.

    ExcelImageFormat imageFormat

    Image format to use for picture storing.

    Returns
    Type Description
    IPictureShape

    Added picture.

    Examples

    The following code illustrates how to add a IPictureShape to the IPictures collection.

    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
        Stream stream = new FileStream("image.png", FileMode.Open);
    
        //Add image
        IPictureShape picture = worksheet.Pictures.AddPicture(1, 1, stream, ExcelImageFormat.Jpeg);
    
        //Save and dispose
        workbook.SaveAs("Shapes.xlsx");
        workbook.Close();
    }

    AddPicture(int, int, Stream, Stream)

    Creates a IPictureShape from the specified svg, its fallback image stream and adds the IPictureShape to the IPictures collection.

    Declaration
    IPictureShape AddPicture(int topRow, int leftColumn, Stream svgStream, Stream imageStream)
    Parameters
    Type Name Description
    int topRow

    Top row of a new picture.

    int leftColumn

    Left column.

    Stream svgStream

    Svg Stream with the picture.

    Stream imageStream

    The Stream of fallback image.

    Returns
    Type Description
    IPictureShape

    Added picture.

    Remarks

    To know more about adding images of type SVG to worksheet refer Adding SVG Images.

    Examples

    The following code illustrates how to add a IPictureShape created with SvgData to the IPictures collection.

    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 from svg
        Stream svgStream = new FileStream("image.svg", FileMode.Open);
    
        //Create image stream from png
        Stream stream = new FileStream("image.png", FileMode.Open);
    
        //Add image
        IPictureShape picture = worksheet.Pictures.AddPicture(1, 1, svgStream, stream);
    
        //Save and dispose
        workbook.SaveAs("Shapes.xlsx");
        workbook.Close();
    }

    AddPicture(int, int, Stream, Stream, int, int)

    Creates a IPictureShape from the specified svg, its fallback image stream and adds the IPictureShape to the IPictures collection with the provided scaling.

    Declaration
    IPictureShape AddPicture(int topRow, int leftColumn, Stream svgStream, Stream imageStream, int scaleWidth, int scaleHeight)
    Parameters
    Type Name Description
    int topRow

    Top row of a new picture.

    int leftColumn

    Left column.

    Stream svgStream

    Svg stream with the picture.

    Stream imageStream

    The Stream instance of fallback image.

    int scaleWidth

    Width scale in percents.

    int scaleHeight

    Height scale in percents.

    Returns
    Type Description
    IPictureShape

    Added picture.

    Remarks

    To know more about adding images of type SVG to worksheet refer Adding SVG Images.

    Examples

    The following code illustrates how to add a IPictureShape created with SvgData to the IPictures collection.

    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 from svg
        Stream svgStream = new FileStream("image.svg", FileMode.Open);
    
        //Create image stream from png
        Stream stream = new FileStream("image.png", FileMode.Open);
    
        //Add image
        IPictureShape picture = worksheet.Pictures.AddPicture(1, 1, svgStream, stream, 50, 50);
    
        //Save and dispose
        workbook.SaveAs("Shapes.xlsx");
        workbook.Close();
    }

    AddPicture(int, int, Stream, int, int)

    Adds IPictureShape to the IPictures collection.

    Declaration
    IPictureShape AddPicture(int topRow, int leftColumn, Stream stream, int scaleWidth, int scaleHeight)
    Parameters
    Type Name Description
    int topRow

    Top row of a new picture.

    int leftColumn

    Left column.

    Stream stream

    Stream with the picture.

    int scaleWidth

    Width scale in percents.

    int scaleHeight

    Height scale in percents.

    Returns
    Type Description
    IPictureShape

    Added picture.

    Examples

    The following code illustrates how to add a IPictureShape to the IPictures collection.

    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
        Stream stream = new FileStream("image.png", FileMode.Open);
    
        //Add image
        IPictureShape picture = worksheet.Pictures.AddPicture(1, 1, stream, 50, 50);
    
        //Save and dispose
        workbook.SaveAs("Shapes.xlsx");
        workbook.Close();
    }

    AddPicture(int, int, Stream, int, int, ExcelImageFormat)

    Adds IPictureShape to the IPictures collection.

    Declaration
    IPictureShape AddPicture(int topRow, int leftColumn, Stream stream, int scaleWidth, int scaleHeight, ExcelImageFormat imageFormat)
    Parameters
    Type Name Description
    int topRow

    Top row of a new picture.

    int leftColumn

    Left column.

    Stream stream

    Stream with the picture.

    int scaleWidth

    Width scale in percents.

    int scaleHeight

    Height scale in percents.

    ExcelImageFormat imageFormat

    Image format to use for picture storing.

    Returns
    Type Description
    IPictureShape

    Added picture.

    Examples

    The following code illustrates how to add a IPictureShape to the IPictures collection.

    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
        Stream stream = new FileStream("image.png", FileMode.Open);
    
        //Add image
        IPictureShape picture = worksheet.Pictures.AddPicture(1, 1, stream, 50, 50, ExcelImageFormat.Jpeg);
    
        //Save and dispose
        workbook.SaveAs("Shapes.xlsx");
        workbook.Close();
    }

    AddPicture(int, int, int, int, Image)

    Adds IPictureShape to the IPictures collection.

    Declaration
    IPictureShape AddPicture(int topRow, int leftColumn, int bottomRow, int rightColumn, Image image)
    Parameters
    Type Name Description
    int topRow

    Top row of a new picture.

    int leftColumn

    Left column.

    int bottomRow

    Bottom row.

    int rightColumn

    Right column.

    Image image

    Image.

    Returns
    Type Description
    IPictureShape

    Added picture.

    Examples

    The following code illustrates how to add a IPictureShape to the IPictures collection.

    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];
    
        //Get image
        System.Drawing.Image image = System.Drawing.Image.FromFile("image.png");
    
        //Add image
        IPictureShape picture = worksheet.Pictures.AddPicture(1, 1, 30, 8, image);
    
        //Save and dispose
        workbook.SaveAs("Shapes.xlsx");
        workbook.Close();
    }

    AddPicture(int, int, int, int, Image, ExcelImageFormat)

    Adds IPictureShape to the IPictures collection.

    Declaration
    IPictureShape AddPicture(int topRow, int leftColumn, int bottomRow, int rightColumn, Image image, ExcelImageFormat imageFormat)
    Parameters
    Type Name Description
    int topRow

    Top row of a new picture.

    int leftColumn

    Left column.

    int bottomRow

    Bottom row.

    int rightColumn

    Right column.

    Image image

    Image to add.

    ExcelImageFormat imageFormat

    Image format to use for picture storing.

    Returns
    Type Description
    IPictureShape

    Added picture.

    Examples

    The following code illustrates how to add a IPictureShape to the IPictures collection.

    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];
    
        //Get image
        System.Drawing.Image image = System.Drawing.Image.FromFile("image.png");
    
        //Add image
        IPictureShape picture = worksheet.Pictures.AddPicture(1, 1, 30, 8, image, ExcelImageFormat.Jpeg);
    
        //Save and dispose
        workbook.SaveAs("Shapes.xlsx");
        workbook.Close();
    }

    AddPicture(int, int, int, int, Stream)

    Adds IPictureShape to the IPictures collection.

    Declaration
    IPictureShape AddPicture(int topRow, int leftColumn, int bottomRow, int rightColumn, Stream stream)
    Parameters
    Type Name Description
    int topRow

    Top row of a new picture.

    int leftColumn

    Left column.

    int bottomRow

    Bottom row.

    int rightColumn

    Right column.

    Stream stream

    Stream with the picture.

    Returns
    Type Description
    IPictureShape

    Added picture.

    Examples

    The following code illustrates how to add a IPictureShape to the IPictures collection.

    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
        Stream stream = new FileStream("image.png", FileMode.Open);
    
        //Add image
        IPictureShape picture = worksheet.Pictures.AddPicture(1, 1, 30, 8, stream);
    
        //Save and dispose
        workbook.SaveAs("Shapes.xlsx");
        workbook.Close();
    }

    AddPicture(int, int, int, int, Stream, ExcelImageFormat)

    Adds IPictureShape to the IPictures collection.

    Declaration
    IPictureShape AddPicture(int topRow, int leftColumn, int bottomRow, int rightColumn, Stream stream, ExcelImageFormat imageFormat)
    Parameters
    Type Name Description
    int topRow

    Top row of a new picture.

    int leftColumn

    Left column.

    int bottomRow

    Bottom row.

    int rightColumn

    Right column.

    Stream stream

    Stream with the picture.

    ExcelImageFormat imageFormat

    Image format to use for picture storing.

    Returns
    Type Description
    IPictureShape

    Added picture.

    Examples

    The following code illustrates how to add a IPictureShape to the IPictures collection.

    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
        Stream stream = new FileStream("image.png", FileMode.Open);
    
        //Add image
        IPictureShape picture = worksheet.Pictures.AddPicture(1, 1, 30, 8, stream, ExcelImageFormat.Jpeg);
    
        //Save and dispose
        workbook.SaveAs("Shapes.xlsx");
        workbook.Close();
    }

    AddPictureAsLink(int, int, int, int, string)

    Adds a IPictureShape from the Url specified to the IPictures collection.

    Declaration
    IPictureShape AddPictureAsLink(int topRow, int leftColumn, int bottomRow, int rightColumn, string url)
    Parameters
    Type Name Description
    int topRow

    Top row of the picture to start with.

    int leftColumn

    Left column of the picture to start with.

    int bottomRow

    Bottom row of the picture to end with.

    int rightColumn

    Right column of the picture to end with.

    string url

    Url of the picture.

    Returns
    Type Description
    IPictureShape

    Added picture.

    Remarks

    To know more about adding images from web refer Adding Images from External Link.

    Examples

    The following code illustrates how to add a IPictureShape from an url specified to the IPictures collection.

    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];
    
        //Add image
        IPictureShape picture = worksheet.Pictures.AddPictureAsLink(1, 1, 5, 7, "https://cdn.syncfusion.com/content/images/company-logos/Syncfusion_Logo_Image.png");
    
        //Save and dispose
        workbook.SaveAs("Shapes.xlsx");
        workbook.Close();
    }
    In this article
    Back to top Generated by DocFX
    Copyright © 2001 - 2026 Syncfusion Inc. All Rights Reserved