Click or drag to resize
ExcelWorksheetPictures Property
Gets the worksheet pictures.

Namespace: GemBox.Spreadsheet
Assembly: GemBox.Spreadsheet (in GemBox.Spreadsheet.dll) Version: 39.3.30.1198
Syntax
public ExcelPictureCollection Pictures { get; }

Property Value

Type: ExcelPictureCollection
The worksheet pictures.
Remarks
Supported picture formats are listed in ExcelPictureFormat.
Examples

Following code demonstrates how to use images:

sheet.Pictures.Add("Image.bmp", 10, 50, 100, 100, LengthUnit.Pixel);
sheet.Pictures.Add("Image.bmp", 10, 50, 100, 100, LengthUnit.Pixel).Position.Mode = PositioningMode.Move;
sheet.Pictures.Add("Image.bmp", "A2").Position.Mode = PositioningMode.MoveAndSize;
sheet.Pictures.Add("Image.bmp", new AnchorCell(sheet.Columns[0], sheet.Rows[1], 10, 10, LengthUnit.Pixel), new AnchorCell(sheet.Columns[3], sheet.Rows[3], false));

// NOTE: pictureStream must not be disposed while it is still used by ExcelFile or exception will be thrown.
var pictureStream = new MemoryStream(File.ReadAllBytes("Image.bmp"));

// Picture format needs to be specified when adding from stream.
sheet.Pictures.Add(pictureStream, ExcelPictureFormat.Bmp, new AnchorCell(sheet.Columns[0], sheet.Rows[1], 10, 10, LengthUnit.Pixel), new AnchorCell(sheet.Columns[3], sheet.Rows[3], false));
See Also