[]
Creates a background picture from an existing file and returns the IBackgroundPicture object that represents the new background picture.
The picture is positioned and sized by the destination rectangle specified in points relative to the upper-left corner of the document.
IBackgroundPicture 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 IBackgroundPicture
| Type | Name | Description |
|---|---|---|
| string | filename | The file from which the background picture is created. |
| double | left | The position, in points, of the upper-left corner of the destination rectangle relative to the upper-left corner of the document. |
| double | top | The position, in points, of the upper-left corner of the destination rectangle relative to the top of the document. |
| double | width | The width of the destination rectangle, in points. |
| double | height | The height of the destination rectangle, in points. |
| Type | Description |
|---|---|
| IBackgroundPicture | The IBackgroundPicture object that represents the new background picture. |
IBackgroundPictures backgroundPictures = worksheet.BackgroundPictures;
string imagePath = CreateSampleImageFile();
try
{
IBackgroundPicture picture = backgroundPictures.AddPicture(imagePath, 12, 18, 160, 90);
}
finally
{
if (File.Exists(imagePath))
{
File.Delete(imagePath);
}
}
| Type | Condition |
|---|---|
| IOException | if the specified file cannot be read. |
Creates a background picture from an existing stream and returns the newly created IBackgroundPicture object.
Use this method to add a background picture at the specified position and size in points.
The left and top parameters specify the upper-left corner of the destination
rectangle relative to the upper-left corner of the document.
IBackgroundPicture 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 IBackgroundPicture
| Type | Name | Description |
|---|---|---|
| Stream | stream | The stream from which the object is to be created. |
| ImageType | type | Specifies the image type of the stream. |
| double | left | The position, in points, of the upper-left corner of the destination rectangle relative to the upper-left corner of the document. |
| double | top | The position, in points, of the upper-left corner of the destination rectangle relative to the top of the document. |
| double | width | The width of the destination rectangle, in points. |
| double | height | The height of the destination rectangle, in points. |
| Type | Description |
|---|---|
| IBackgroundPicture | The newly created IBackgroundPicture object. |
IBackgroundPictures backgroundPictures = worksheet.BackgroundPictures;
IBackgroundPicture picture = null;
using (MemoryStream stream = CreateSampleImageStream())
{
picture = backgroundPictures.AddPicture(stream, ImageType.PNG, 12, 18, 120, 80);
picture.BackgroundImageLayout = ImageLayout.Center;
}
| Type | Condition |
|---|---|
| IOException | if an I/O error occurs while reading the image stream. |