Click or drag to resize
ExcelPicture Class
Represents a picture in the worksheet.
Inheritance Hierarchy

Namespace:  GemBox.Spreadsheet
Assembly:  GemBox.Spreadsheet (in GemBox.Spreadsheet.dll) Version: 41.3.30.1018
Syntax
public sealed class ExcelPicture : ExcelDrawing

The ExcelPicture type exposes the following members.

Properties
  NameDescription
Public propertyHasHyperlink Obsolete.
Gets a value indicating whether this drawing (picture, chart, etc.) has hyperlink.
(Inherited from ExcelDrawing.)
Public propertyHyperlink
Gets or sets the hyperlink on this drawing (picture, chart, etc.).
(Inherited from ExcelDrawing.)
Public propertyMetadata
Gets the metadata (non-visual properties) of this ExcelDrawing instance.
(Inherited from ExcelDrawing.)
Public propertyPictureFormat
Gets the picture format.
Public propertyPictureStream
Gets the picture stream.
Public propertyPosition
Gets the position of this drawing (picture, chart, etc.) in the worksheet.
(Inherited from ExcelDrawing.)
Top
Methods
  NameDescription
Public methodDelete
Removes this ExcelPicture instance from the worksheet.
Public methodFormat
Formats this drawing (picture, chart, etc.) to its default size so it can be exported to PDF, XPS, image or be printed.
(Inherited from ExcelDrawing.)
Public methodFormat(Double, Double, LengthUnit)
Formats this drawing (picture, chart, etc.) to specified size so it can be exported to PDF, XPS, image or be printed.
(Inherited from ExcelDrawing.)
Public methodToImage
Converts this ExcelPicture instance to a new Image instance.
Public methodToString
Returns a String that represents this ExcelPicture instance.
(Overrides ObjectToString.)
Top
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