ChartToImage Method (String, ImageOrPrintOptions)

Creates the chart image and saves it to a file. The extension of the file name determines the format of the image.

Namespace:  Aspose.Cells.Charts
Assembly:  Aspose.Cells (in Aspose.Cells.dll) Version: 21.6.0.0 (21.6)
Syntax
public void ToImage(
	string imageFile,
	ImageOrPrintOptions options
)

Parameters

imageFile
Type: SystemString
The image file name with full path.
options
Type: Aspose.Cells.RenderingImageOrPrintOptions
Additional image creation options
Remarks

The format of the image is specified by using the extension of the file name. For example, if you specify "myfile.png", then the image will be saved in the PNG format. The following file extensions are recognized: .bmp, .gif, .png, .jpg, .jpeg, .tiff, .tif, .emf.

If the width or height is zero or the chart is not supported according to Supported Charts List, this method will do nothing. Please refer to Supported Charts List for more details.
Examples
Saves to Tiff with 300 dpi and CCITT4 compression.
[C#]
ImageOrPrintOptions options = new ImageOrPrintOptions();
options.HorizontalResolution = 300;
options.VerticalResolution = 300;
options.TiffCompression = TiffCompression.CompressionCCITT4;

Workbook book = new Workbook(@"c:\test.xls");
book.Worksheets[0].Charts[0].ToImage(@"c:\chart.Tiff", options);

[VB]
Dim options As ImageOrPrintOptions =  New ImageOrPrintOptions() 
options.HorizontalResolution = 300
options.VerticalResolution = 300
options.TiffCompression = TiffCompression.CompressionCCITT4

Dim book As Workbook =  New Workbook("c:\test.xls")
book.Worksheets(0).Charts(0).ToImage("c:\chart.Tiff", options)
Saves to Jpeg with 300 dpi and 80 image quality.
[C#]
ImageOrPrintOptions options = new ImageOrPrintOptions();
options.HorizontalResolution = 300;
options.VerticalResolution = 300;
options.Quality = 80;

Workbook book = new Workbook(@"c:\test.xls");
book.Worksheets[0].Charts[0].ToImage(@"c:\chart.Jpeg", options);

[VB]
Dim options As ImageOrPrintOptions =  New ImageOrPrintOptions()
options.HorizontalResolution = 300
options.VerticalResolution = 300
options.Quality = 80

Dim book As Workbook =  New Workbook("c:\test.xls")
book.Worksheets(0).Charts(0).ToImage("c:\chart.Jpeg", options)
See Also