Click or drag to resize
ExcelPictureCollection Class
Represents a collection of pictures in the worksheet.
Inheritance Hierarchy
SystemObject
  GemBox.SpreadsheetExcelDrawingCollectionExcelPicture
    GemBox.SpreadsheetExcelPictureCollection

Namespace: GemBox.Spreadsheet
Assembly: GemBox.Spreadsheet (in GemBox.Spreadsheet.dll) Version: 41.3.30.1000
Syntax
public sealed class ExcelPictureCollection : ExcelDrawingCollection<ExcelPicture>

The ExcelPictureCollection type exposes the following members.

Methods
  NameDescription
Public methodAdd(String, AnchorCell)
Adds a new picture to the worksheet which moves but doesn't size with cells. Picture size will be determined by using GDI+.
Public methodAdd(String, String)
Adds a new picture to the worksheet which moves but doesn't size with cells. Picture size will be determined by using GDI+.
Public methodAdd(String, AnchorCell, AnchorCell)
Adds a new picture to the worksheet which moves and sizes with cells.
Public methodAdd(String, String, String)
Adds a new picture to the worksheet which moves and sizes with cells.
Public methodAdd(MemoryStream, ExcelPictureFormat, AnchorCell, AnchorCell)
Adds a new picture to the worksheet which moves and sizes with cells.
Public methodAdd(MemoryStream, ExcelPictureFormat, String, String)
Adds a new picture to the worksheet which moves and sizes with cells.
Public methodAdd(String, Double, Double, LengthUnit)
Adds a new picture to the worksheet which doesn't move nor sizes with cells. Picture size will be determined by using GDI+.
Public methodAdd(String, AnchorCell, Double, Double, LengthUnit)
Adds a new picture to the worksheet which moves but doesn't size with cells.
Public methodAdd(String, String, Double, Double, LengthUnit)
Adds a new picture to the worksheet which moves but doesn't size with cells.
Public methodAdd(MemoryStream, ExcelPictureFormat, AnchorCell, Double, Double, LengthUnit)
Adds a new picture to the worksheet which moves but doesn't size with cells.
Public methodAdd(MemoryStream, ExcelPictureFormat, String, Double, Double, LengthUnit)
Adds a new picture to the worksheet which moves but doesn't size with cells.
Public methodAdd(String, Double, Double, Double, Double, LengthUnit)
Adds a new picture to the worksheet which doesn't move nor sizes with cells.
Public methodAdd(MemoryStream, ExcelPictureFormat, Double, Double, Double, Double, LengthUnit)
Adds a new picture to the worksheet which doesn't move nor sizes with cells.
Public methodAddCopy
Adds a copy of the drawing (picture, chart, etc.) to the worksheet.
(Inherited from ExcelDrawingCollectionT.)
Public methodClear (Inherited from ExcelDrawingCollectionT.)
Public methodContains (Inherited from ExcelDrawingCollectionT.)
Public methodGetEnumerator
Returns an enumerator that iterates through the collection.
(Inherited from ExcelDrawingCollectionT.)
Public methodIndexOf (Inherited from ExcelDrawingCollectionT.)
Public methodRemove (Inherited from ExcelDrawingCollectionT.)
Public methodRemoveAt (Inherited from ExcelDrawingCollectionT.)
Top
Properties
Explicit Interface Implementations
  NameDescription
Explicit interface implementationPrivate methodICollectionTAdd (Inherited from ExcelDrawingCollectionT.)
Explicit interface implementationPrivate methodICollectionTCopyTo (Inherited from ExcelDrawingCollectionT.)
Explicit interface implementationPrivate methodIEnumerableGetEnumerator
Returns an enumerator that iterates through a collection.
(Inherited from ExcelDrawingCollectionT.)
Explicit interface implementationPrivate methodIListTInsert (Inherited from ExcelDrawingCollectionT.)
Explicit interface implementationPrivate propertyICollectionTIsReadOnly (Inherited from ExcelDrawingCollectionT.)
Explicit interface implementationPrivate propertyIListTItem
Gets or sets the element at the specified index.
(Inherited from ExcelDrawingCollectionT.)
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