[]
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).
void UserPicture(string fileName)
Sub UserPicture(fileName As String)
| Type | Name | Description |
|---|---|---|
| string | fileName | The name of the picture file. |
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);
}
}
| Type | Condition |
|---|---|
| IOException | if the picture file cannot be read. |
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.
void UserPicture(Stream stream, ImageType type)
Sub UserPicture(stream As Stream, type As ImageType)
| Type | Name | Description |
|---|---|---|
| Stream | stream | The stream of the picture file. |
| ImageType | type | The ImageType of the stream. |
IShape shape = worksheet.Shapes.AddShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
IFillFormat fillFormat = shape.Fill;
using (MemoryStream stream = CreateSampleImageStream())
{
fillFormat.UserPicture(stream, ImageType.PNG);
}
| Type | Condition |
|---|---|
| IOException | if an I/O error occurs while reading the image stream. |