Skip to main content
A newer version of this page is available. .

IXlPicture.StretchToCell(XlCellPosition) Method

Stretches an IXlPicture object to fill the specified cell.

Namespace: DevExpress.Export.Xl

Assembly: DevExpress.Printing.v18.2.Core.dll

Declaration

void StretchToCell(
    XlCellPosition position
)

Parameters

Name Type Description
position XlCellPosition

An XlCellPosition object that specifies the position of the cell where the picture should be located.

Remarks

Use the StretchToCell method to stretch your image both vertically and horizontally to fill the entire space of a desired cell. To resize a picture to fit a particular cell but retain the picture’s proportions, use the IXlPicture.FitToCell method

For more information on how to add a picture to a worksheet and specify its location, refer to the How to: Insert and Position a Picture in a Worksheet example.

Example

Note

A complete sample project is available at https://github.com/DevExpress-Examples/xl-export-api-examples-t253492

    // Insert a picture from a file and stretch it to fill the cell B2.
    using (IXlPicture picture = sheet.CreatePicture())
    {
        picture.Image = Image.FromFile(Path.Combine(imagesPath, "image1.jpg"));
        picture.StretchToCell(new XlCellPosition(1, 1));
    }
}
See Also