.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+

PictureCollection.AddPicture(String, Cell) Method

Inserts a picture from a file so that the top left corner of the picture is located at the specified cell.

Namespace: DevExpress.Spreadsheet

Assembly: DevExpress.Spreadsheet.v20.2.Core.dll


Picture AddPicture(
    string filename,
    Cell topLeftCell


Name Type Description
filename String

A string that specifies a path to the image file.

topLeftCell Cell

A Cell where the top left corner of the picture is located.


Type Description

A Picture object that is the inserted picture.


The inserted picture has FloatingObject.Placement set to Placement.Move.


Dim imageStream As Stream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("Pictures.x-spreadsheet.png")
Dim imageSource As SpreadsheetImageSource = SpreadsheetImageSource.FromStream(imageStream)
' Set the measurement unit to Millimeter.
workbook.Unit = DevExpress.Office.DocumentUnit.Millimeter
    Dim worksheet As Worksheet = workbook.Worksheets(0)
    ' Insert a picture from a file so that its top left corner is in the specified cell.
    ' By default the picture is named Picture1.. PictureNN.
    worksheet.Pictures.AddPicture("Pictures\x-docserver.png", worksheet.Cells("D5"))
    ' Insert a picture to fit in the specified range.
    worksheet.Pictures.AddPicture("Pictures\x-docserver.png", worksheet.Range("B2"))
    ' Insert a picture from the SpreadsheetImageSource at 120 mm from the left, 80 mm from the top, 
    ' and resize it to a width of 70 mm and a height of 20 mm, locking the aspect ratio.
    worksheet.Pictures.AddPicture(imageSource, 120, 80, 70, 20, True)
    ' Insert the picture to be removed.
    worksheet.Pictures.AddPicture("Pictures\x-docserver.png", 0, 0)
    ' Remove the last inserted picture.
    ' Find the Picture by its name. The method returns a collection of Pictures with the same name.
    Dim pic As Picture = worksheet.Pictures.GetPicturesByName("Picture 4")(0)
End Try
See Also