to_image method

to_image

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

def to_image(self, image_file):
    ...
ParameterTypeDescription
image_filestrThe 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.

to_image

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

def to_image(self, image_file, image_type):
    ...
ParameterTypeDescription
image_filestrThe image file name with full path.
image_typeaspose.cells.drawing.ImageTypeThe 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.

to_image

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

def to_image(self, image_file, jpeg_quality):
    ...
ParameterTypeDescription
image_filestrThe image file name with full path.
jpeg_qualityintJpeg 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.

to_image

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

def to_image(self, stream, jpeg_quality):
    ...
ParameterTypeDescription
streamio.RawIOBaseThe output stream.
jpeg_qualityintJpeg 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.

to_image

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

def to_image(self, stream, image_type):
    ...
ParameterTypeDescription
streamio.RawIOBaseThe output stream.
image_typeaspose.cells.drawing.ImageTypeThe 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.

to_image

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

def to_image(self, image_file, options):
    ...
ParameterTypeDescription
image_filestrThe image file name with full path.
optionsaspose.cells.rendering.ImageOrPrintOptionsAdditional 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.

Example

Saves to Tiff with 300 dpi and CCITT4 compression.

from aspose.cells import Workbook
from aspose.cells.rendering import ImageOrPrintOptions, TiffCompression

options = ImageOrPrintOptions()
options.horizontal_resolution = 300
options.vertical_resolution = 300
options.tiff_compression = TiffCompression.COMPRESSION_CCITT4
book = Workbook(r"test.xls")
book.worksheets[0].charts[0].to_image(r"chart.Tiff", options)

Saves to Jpeg with 300 dpi and 80 image quality.

from aspose.cells import Workbook
from aspose.cells.rendering import ImageOrPrintOptions

options = ImageOrPrintOptions()
options.horizontal_resolution = 300
options.vertical_resolution = 300
options.quality = 80
book = Workbook(r"test.xls")
book.worksheets[0].charts[0].to_image(r"chart.Jpeg", options)

to_image

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

def to_image(self, stream, options):
    ...
ParameterTypeDescription
streamio.RawIOBaseThe output stream.
optionsaspose.cells.rendering.ImageOrPrintOptionsAdditional 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