to_image method

to_image

Render certain page to a file.

def to_image(self, page_index, file_name):
    ...
ParameterTypeDescription
page_indexintindicate which page is to be converted
file_namestrfilename of the output image

Example

The following code outputs the first page of the first sheet to png image.

from aspose.cells import Workbook
from aspose.cells.drawing import ImageType
from aspose.cells.rendering import ImageOrPrintOptions, SheetRender

# load the source file with images.
wb = Workbook("Book1.xlsx")
imgOpt = ImageOrPrintOptions()
# set output image type.
imgOpt.image_type = ImageType.PNG
# render the first sheet.
sr = SheetRender(wb.worksheets[0], imgOpt)
# output the first page of the sheet to image.
sr.to_image(0, "output.png")

to_image

Render certain page to a stream.

def to_image(self, page_index, stream):
    ...
ParameterTypeDescription
page_indexintindicate which page is to be converted
streamio.RawIOBasethe stream of the output image

See Also