Back to Devexpress

CellRangeExtensions.ExportToImage(CellRange, Stream, ImageFileFormat) Method

officefileapi-devexpress-dot-spreadsheet-dot-cellrangeextensions-dot-exporttoimage-x28-devexpress-dot-spreadsheet-dot-cellrange-system-dot-io-dot-stream-devexpress-dot-spreadsheet-dot-imagefileformat-x29.md

latest2.9 KB
Original Source

CellRangeExtensions.ExportToImage(CellRange, Stream, ImageFileFormat) Method

Exports the cell range to an image in the specified format.

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

Declaration

csharp
public static void ExportToImage(
    this CellRange range,
    Stream stream,
    ImageFileFormat format
)
vb
<ExtensionAttribute>
Public Shared Sub ExportToImage(
    range As CellRange,
    stream As Stream,
    format As ImageFileFormat
)

Parameters

NameTypeDescription
rangeCellRange

The cell range to be exported to an image.

| | stream | Stream |

A stream used to save the output image.

| | format | ImageFileFormat |

The output image format.

|

Exceptions

TypeDescription
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:

csharp
using DevExpress.Spreadsheet;
using System.IO;
// ...

using (FileStream imageStream = new FileStream("RangeImage.png", FileMode.Create))
{
    worksheet.Range["B1:I25"].ExportToImage(imageStream, ImageFileFormat.Png);
}
vb
Imports DevExpress.Spreadsheet
Imports System.IO
' ...

Using imageStream As New FileStream("RangeImage.png", FileMode.Create)
    worksheet.Range("B1:I25").ExportToImage(imageStream, ImageFileFormat.Png)
End Using

See Also

CellRangeExtensions Class

CellRangeExtensions Members

DevExpress.Spreadsheet Namespace