Chart.ToImage

ToImage()

Gets a 32-bit Bitmap object of the chart.

public Bitmap ToImage()

Return Value

the picture of the chart.

Remarks

If the width or height is zero or the chart is not supported according to Supported Charts List, it will return null.

See Also


ToImage(ImageOrPrintOptions)

Gets a 32-bit Bitmap object of the chart. ImageOrPrintOptions.ImageFormat, ImageOrPrintOptions.TiffCompression and ImageOrPrintOptions.Quality attributes are ignored.

public Bitmap ToImage(ImageOrPrintOptions options)
ParameterTypeDescription
optionsImageOrPrintOptionsAdditional image creation options

Return Value

the picture of the chart.

Remarks

Returns a 32-bit bitmap object, so ImageOrPrintOptions.ImageFormat, ImageOrPrintOptions.TiffCompression and ImageOrPrintOptions.Quality attributes do not affect the method. If the width or height is zero or the chart is not supported according to Supported Charts List, it will return null.

Examples

Gets a bitmap object with 200 x dpi and 300 y dpi.


[C#]
ImageOrPrintOptions options = new ImageOrPrintOptions();
options.HorizontalResolution = 200;
options.VerticalResolution = 300;

Workbook book = new Workbook(@"test.xls");
Bitmap chartObject = book.Worksheets[0].Charts[0].ToImage(options);

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

Dim book As Workbook =  New Workbook("test.xls")
Dim chartObject As Bitmap = book.Worksheets(0).Charts(0).ToImage(options)

See Also


ToImage(string)

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

public void ToImage(string imageFile)
ParameterTypeDescription
imageFileStringThe image file name with full path.

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.

See Also


ToImage(string, ImageFormat)

Creates the chart image and saves it to a file in the specified format.

[Obsolete("Use Chart.ToImage(string, ImageType) method instead.")]
public void ToImage(string imageFile, ImageFormat imageFormat)
ParameterTypeDescription
imageFileStringThe image file name with full path.
imageFormatImageFormatThe format in which to save the image.

Remarks

NOTE: This member is now obsolete. Instead, please use Chart.ToImage(string, ImageType) method. This property will be removed 12 months later since July 2022. Aspose apologizes for any inconvenience you may have experienced.

See Also


ToImage(string, ImageType)

Creates the chart image and saves it to a file in the specified image type.

public void ToImage(string imageFile, ImageType imageType)
ParameterTypeDescription
imageFileStringThe image file name with full path.
imageTypeImageTypeThe image type in which to save the image.

Remarks

The type of the image is specified by using imageType. The following types are supported: ImageType.Bmp, ImageType.Gif, ImageType.Png, ImageType.Jpeg, ImageType.Tiff, ImageType.Emf.

If the width or height is zero or the chart is not supported according to Supported Charts List, this method will do nothing.

See Also


ToImage(string, long)

Creates the chart image and saves it to a file in the Jpeg format.

public void ToImage(string imageFile, long jpegQuality)
ParameterTypeDescription
imageFileStringThe image file name with full path.
jpegQualityInt64Jpeg quality.

Remarks

If the width or height is zero or the chart is not supported according to Supported Charts List, this method will do nothing.

See Also


ToImage(Stream, long)

Creates the chart image and saves it to a stream in the Jpeg format.

public void ToImage(Stream stream, long jpegQuality)
ParameterTypeDescription
streamStreamThe output stream.
jpegQualityInt64Jpeg quality.

Remarks

If the width or height is zero or the chart is not supported according to Supported Charts List, this method will do nothing.

See Also


ToImage(Stream, ImageFormat)

Creates the chart image and saves it to a stream in the specified format.

[Obsolete("Use Chart.ToImage(Stream, ImageType) method instead.")]
public void ToImage(Stream stream, ImageFormat imageFormat)
ParameterTypeDescription
streamStreamThe output stream.
imageFormatImageFormatThe format in which to save the image.

Remarks

NOTE: This member is now obsolete. Instead, please use Chart.ToImage(Stream, ImageType) method. This property will be removed 12 months later since July 2022. Aspose apologizes for any inconvenience you may have experienced.

See Also


ToImage(Stream, ImageType)

Creates the chart image and saves it to a stream in the specified format.

public void ToImage(Stream stream, ImageType imageType)
ParameterTypeDescription
streamStreamThe output stream.
imageTypeImageTypeThe image type in which to save the image.

Remarks

The type of the image is specified by using imageType. The following types are supported: ImageType.Bmp, ImageType.Gif, ImageType.Png, ImageType.Jpeg, ImageType.Tiff, ImageType.Emf.

If the width or height is zero or the chart is not supported according to Supported Charts List, this method will do nothing.

See Also


ToImage(string, ImageOrPrintOptions)

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

public void ToImage(string imageFile, ImageOrPrintOptions options)
ParameterTypeDescription
imageFileStringThe image file name with full path.
optionsImageOrPrintOptionsAdditional 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(@"test.xls");
book.Worksheets[0].Charts[0].ToImage(@"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("test.xls")
book.Worksheets(0).Charts(0).ToImage("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(@"test.xls");
book.Worksheets[0].Charts[0].ToImage(@"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("test.xls")
book.Worksheets(0).Charts(0).ToImage("chart.Jpeg", options)

See Also


ToImage(Stream, ImageOrPrintOptions)

Creates the chart image and saves it to a stream in the specified format.

public void ToImage(Stream stream, ImageOrPrintOptions options)
ParameterTypeDescription
streamStreamThe output stream.
optionsImageOrPrintOptionsAdditional image creation options

Remarks

The type of the image is specified by using options.ImageType. The following formats are supported: ImageType.Bmp, ImageType.Gif, ImageType.Png, ImageType.Jpeg, ImageType.Tiff, ImageType.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.

See Also