[]
        
(Showing Draft Content)

GrapeCity.Documents.Excel.Drawing.IChart.AddPicture

AddPicture Method

AddPicture(string, double, double, double, double)

Creates a picture from an existing file and adds it to the chart.

The picture is positioned relative to the chart area. The left, top, width, and height values are measured in points.

Declaration
IShape AddPicture(string filename, double left, double top, double width, double height)
Function AddPicture(filename As String, left As Double, top As Double, width As Double, height As Double) As IShape
Parameters
Type Name Description
string filename

The file from which the picture is created.

double left

The distance from the left edge of the picture to the left edge of the chart area, in points.

double top

The distance from the top edge of the picture to the top edge of the chart area, in points.

double width

The width of the picture, in points.

double height

The height of the picture, in points.

Returns
Type Description
IShape

The IShape object that represents the new picture.

Examples
string imagePath = System.IO.Path.Combine("Users", "DefaultApps", "Documents", "logo.png");
IChart chart = worksheet.Shapes.AddChart(ChartType.ColumnClustered, 20, 20, 300, 200).Chart;
IShape picture = chart.AddPicture(imagePath, 40, 30, 120, 80);
picture.Name = "Logo";

AddPicture(Stream, ImageType, double, double, double, double)

Creates a picture from an existing stream and adds it to the chart.

The picture is positioned relative to the chart area. The left, top, width, and height values are measured in points.

Declaration
IShape AddPicture(Stream stream, ImageType type, double left, double top, double width, double height)
Function AddPicture(stream As Stream, type As ImageType, left As Double, top As Double, width As Double, height As Double) As IShape
Parameters
Type Name Description
Stream stream

The stream that provides the picture data. Must not be null.

ImageType type

The type of the picture data in the stream.

double left

The distance from the left edge of the picture to the left edge of the chart area, in points.

double top

The distance from the top edge of the picture to the top edge of the chart area, in points.

double width

The width of the picture, in points.

double height

The height of the picture, in points.

Returns
Type Description
IShape

The IShape object that represents the new picture.

Examples
IChart chart = worksheet.Shapes.AddChart(ChartType.ColumnClustered, 20, 20, 300, 200).Chart;
byte[] pictureBytes = Convert.FromBase64String("iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVQIHWP4////fwAJ+wP9KobjigAAAABJRU5ErkJggg==");
IShape picture;
using (MemoryStream stream = new MemoryStream(pictureBytes))
{
    picture = chart.AddPicture(stream, ImageType.PNG, 40, 30, 120, 80);
}