[]
        
(Showing Draft Content)

GrapeCity.Documents.Excel.Drawing.IFillFormat.UserPicture

UserPicture Method

UserPicture(string)

Fills the specified shape with an image.

Use this method to apply an image file as the fill for a shape. To fill the shape with small tiles of an image, use UserTextured(string).

Declaration
void UserPicture(string fileName)
Sub UserPicture(fileName As String)
Parameters
Type Name Description
string fileName

The name of the picture file.

Examples
IShape shape = worksheet.Shapes.AddShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
IFillFormat fillFormat = shape.Fill;
string imagePath = CreateSampleImageFile();
try
{
    fillFormat.UserPicture(imagePath);
}
finally
{
    if (File.Exists(imagePath))
    {
        File.Delete(imagePath);
    }
}
Exceptions
Type Condition
IOException

if the picture file cannot be read.

UserPicture(Stream, ImageType)

Fills the specified shape with an image.

Use this method to apply a picture fill from a Stream. Specify the image format with the ImageType parameter.

Declaration
void UserPicture(Stream stream, ImageType type)
Sub UserPicture(stream As Stream, type As ImageType)
Parameters
Type Name Description
Stream stream

The stream of the picture file.

ImageType type

The ImageType of the stream.

Examples
IShape shape = worksheet.Shapes.AddShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
IFillFormat fillFormat = shape.Fill;
using (MemoryStream stream = CreateSampleImageStream())
{
    fillFormat.UserPicture(stream, ImageType.PNG);
}
Exceptions
Type Condition
IOException

if an I/O error occurs while reading the image stream.