Skip to main content

IXlPicture.SourceRectangle Property

Gets or sets the portion of the picture to draw.

Namespace: DevExpress.Export.Xl

Assembly: DevExpress.Printing.v24.1.Core.dll

NuGet Package: DevExpress.Printing.Core

Declaration

XlSourceRectangle SourceRectangle { get; set; }

Property Value

Type Description
XlSourceRectangle

An XlSourceRectangle object that specifies the source rectangle’s offsets from the corresponding edges of the picture’s bounding box.

Remarks

Use the SourceRectangle property to crop an image inserted into the document. Each edge of the source rectangle is defined by a percentage offset from the corresponding edge of the bounding box. A positive percentage specifies an inset, while a negative percentage specifies an outset. For example, a left offset of 30% (XlSourceRectangle.Left is 0.3) specifies that the leftmost 30% of the picture will be cropped and the remaining part of the picture will be shown.

If you set the XlSourceRectangle properties to negative values, an empty space will appear along the corresponding edges of the picture. For example, the left and right offsets of -10% (XlSourceRectangle.Left and XlSourceRectangle.Right is -0.1) specifies that two blank bands of equal width (10% of the picture’s width) will be shown along the left and right edges of the picture.

The following table demonstrates how the SourceRectangle property works (the result is shown in Microsoft® Excel®).

Original Image

(XlSourceRectangle is not specified)

XlSourceRectangle.Left = 0.3

XlSourceRectangle.Left = -0.1

XlSourceRectangle.Right = -0.1

XLExport_SourceRect_NoCropping

XLExport_SourceRect_CropImage

XLExport_SourceRect_SqueezeImage

See Also