[]
        
(Showing Draft Content)

GrapeCity.Documents.Excel.IWorksheet.ToImage

ToImage Method

ToImage(string)

Saves the worksheet to the specified image file.

Use this method to export the current worksheet as an image.

Declaration
void ToImage(string imageFile)
Sub ToImage(imageFile As String)
Parameters
Type Name Description
string imageFile

The path and file name of the output image file.

Examples
worksheet.Range["A1:B2"].Value = new object[,] {
    {"Name", "Value"},
    {"Test", 100}
};
worksheet.ToImage("worksheet.png");

ToImage(string, ImageSaveOptions)

Saves the worksheet to the specified image file using options.

Declaration
void ToImage(string imageFile, ImageSaveOptions options)
Sub ToImage(imageFile As String, options As ImageSaveOptions)
Parameters
Type Name Description
string imageFile

The output image file.

ImageSaveOptions options

The options for output image.

Examples
worksheet.Range["A1"].Value = "Sample";
ImageSaveOptions options = new ImageSaveOptions();
worksheet.ToImage("path/to/output.png", options);

ToImage(Stream, ImageType)

Saves the worksheet to the specified image stream.

Declaration
void ToImage(Stream stream, ImageType imageType)
Sub ToImage(stream As Stream, imageType As ImageType)
Parameters
Type Name Description
Stream stream

The specified image stream.

ImageType imageType

Specifies the type of image to create.

Examples
worksheet.Range["A1"].Value = "Sample";
MemoryStream stream = new MemoryStream();
worksheet.ToImage(stream, ImageType.PNG);

ToImage(Stream, ImageType, ImageSaveOptions)

Saves the worksheet to the specified image stream using options.

Declaration
void ToImage(Stream stream, ImageType imageType, ImageSaveOptions options)
Sub ToImage(stream As Stream, imageType As ImageType, options As ImageSaveOptions)
Parameters
Type Name Description
Stream stream

The specified image stream.

ImageType imageType

Specifies the type of image to create.

ImageSaveOptions options

The options for output image.

Examples
worksheet.Range["A1"].Value = "Sample";
MemoryStream stream = new MemoryStream();
ImageSaveOptions options = new ImageSaveOptions();
worksheet.ToImage(stream, ImageType.PNG, options);