[]
Saves the shape to the specified image file.
The generated image displays the rectangular worksheet area enclosed by the shape. This method can be used with shapes such as AutoShapes, pictures, slicers, and charts.
void ToImage(string fileName)
Sub ToImage(fileName As String)
| Type | Name | Description |
|---|---|---|
| string | fileName | The output image file. |
IShape shape = worksheet.Shapes.AddShape(AutoShapeType.Oval, 20, 20, 160, 80);
string imagePath = "ShapeToImage.png";
shape.ToImage(imagePath);
Saves the shape to the specified image file using options.
The generated image displays the rectangular worksheet area enclosed by the shape.
This method can be used with shapes such as AutoShapes, pictures, slicers, and charts.
Use options to control how the output image is generated.
void ToImage(string fileName, ImageSaveOptions options)
Sub ToImage(fileName As String, options As ImageSaveOptions)
| Type | Name | Description |
|---|---|---|
| string | fileName | The output image file. |
| ImageSaveOptions | options | The options for output image. |
IShape shape = worksheet.Shapes.AddShape(AutoShapeType.Oval, 20, 20, 160, 80);
ImageSaveOptions options = new ImageSaveOptions();
options.ScaleX = 2.0;
string imagePath = "ShapeToImage.png";
shape.ToImage(imagePath, options);
Saves the shape to the specified image stream.
Use imageType to control the output format of the generated image.
To customize the exported image, use ToImage(Stream, ImageType, ImageSaveOptions).
void ToImage(Stream stream, ImageType imageType)
Sub ToImage(stream As Stream, imageType As ImageType)
| Type | Name | Description |
|---|---|---|
| Stream | stream | The output image stream to receive the generated image. This value cannot be null. |
| ImageType | imageType | Specifies the type of image to create. |
IShape shape = worksheet.Shapes.AddShape(AutoShapeType.Rectangle, 20, 20, 120, 60);
shape.Name = "SalesBox";
MemoryStream stream = new MemoryStream();
shape.ToImage(stream, ImageType.PNG);
Saves the shape to the specified image stream using options.
Use this method to export the current shape as an image in the specified format. The generated image is written to the provided Stream.
void ToImage(Stream stream, ImageType imageType, ImageSaveOptions options)
Sub ToImage(stream As Stream, imageType As ImageType, options As ImageSaveOptions)
| Type | Name | Description |
|---|---|---|
| Stream | stream | The output image stream. |
| ImageType | imageType | Specifies the type of image to create. |
| ImageSaveOptions | options | The options for output image. This value can be null. |
IShape shape = worksheet.Shapes.AddShape(AutoShapeType.Rectangle, 20, 20, 120, 60);
MemoryStream stream = new MemoryStream();
ImageSaveOptions options = new ImageSaveOptions();
shape.ToImage(stream, ImageType.PNG, options);