Skip to main content
All docs
V23.2
Row

CellRangeExtensions.ExportToImage(CellRange, RangeImageOptions) Method

Exports the cell range to an image and allows you to specify export options.

You need a license for the DevExpress Office File API Subscription or DevExpress Universal Subscription to use this method in production code.

Namespace: DevExpress.Spreadsheet

Assembly: DevExpress.Docs.v23.2.dll

NuGet Package: DevExpress.Document.Processor

Declaration

public static OfficeImage ExportToImage(
    this CellRange range,
    RangeImageOptions options
)

Parameters

Name Type Description
range CellRange

The cell range to be exported to an image.

options RangeImageOptions

An object that defines export options.

Returns

Type Description
OfficeImage

The output image.

Exceptions

Type Description
InvalidOperationException

Occurs when you call this method for a union range that consists of non-adjacent cell ranges.

Remarks

The following example demonstrates how to export a cell range to an image:

Spreadsheet - Export a Cell Range to an Image and Set Export Options

using DevExpress.Spreadsheet;
using System.Drawing;
// ...

var exportOptions = new RangeImageOptions
{
    Resolution = 192,
    ExportHeadings = true,
    ExportGridlines = true,
    GridlineColor = Color.Gray,
    BackgroundColor = Color.FromArgb(0xF2, 0xF2, 0xF2)
};
worksheet.Range["B1:I25"].ExportToImage(exportOptions).NativeImage.Save("RangeImage.png");
See Also