Skip to main content

IXlPicture.StretchToCell(XlCellPosition) Method

Stretches an IXlPicture object to fill the specified cell.

Namespace: DevExpress.Export.Xl

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

NuGet Package: DevExpress.Printing.Core

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/excel-export-api-examples

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

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the StretchToCell(XlCellPosition) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also