officefileapi-devexpress-dot-spreadsheet-dot-cellrangeextensions-dot-exporttoimage-x28-cellrange-string-imagefileformat-rangeimageoptions-x29.md
Exports the cell range to an image in the specified format 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.v25.2.dll
NuGet Package : DevExpress.Document.Processor
public static void ExportToImage(
this CellRange range,
string fileName,
ImageFileFormat format,
RangeImageOptions options
)
<ExtensionAttribute>
Public Shared Sub ExportToImage(
range As CellRange,
fileName As String,
format As ImageFileFormat,
options As RangeImageOptions
)
| Name | Type | Description |
|---|---|---|
| range | CellRange |
The cell range to be exported to an image.
| | fileName | String |
The file name (including the full path) for the output image.
| | format | ImageFileFormat |
The output image format.
| | options | RangeImageOptions |
An object that defines export options.
|
| Type | Description |
|---|---|
| InvalidOperationException |
Occurs when you call this method for a union range that consists of non-adjacent cell ranges.
|
The following example demonstrates how to export a cell range to an image:
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("RangeImage.png", ImageFileFormat.Png, exportOptions);
Imports DevExpress.Spreadsheet
Imports System.Drawing
' ...
Dim exportOptions As New RangeImageOptions With {
.Resolution = 192,
.ExportHeadings = True,
.ExportGridlines = True,
.GridlineColor = Color.Gray,
.BackgroundColor = Color.FromArgb(&HF2, &HF2, &HF2)
}
worksheet.Range("B1:I25").ExportToImage("RangeImage.png", ImageFileFormat.Png, exportOptions)
See Also