WorkbookRender

WorkbookRender class

Represents a Workbook render. The constructor of this class , must be used after modification of pagesetup, cell style.

Constructors

NameDescription
WorkbookRenderThe construct of WorkbookRender

Properties

NameTypeDescription
PageCountintGets the total page count of workbook.

Methods

NameDescription
getPageSizeInchGet page size in inch of output image.
toImageRender whole workbook as Tiff Image to a file.
toPrinterRender workbook to Printer
toImageBytesRender whole workbook as Tiff Image to a byte array.

WorkbookRender(workbook, options)

The construct of WorkbookRender

ParameterTypeDescription
workbookWorkbookIndicate which workbook to be rendered.
optionsImageOrPrintOptionsImageOrPrintOptions contains some property of output image

WorkbookRender.PageCount property

Gets the total page count of workbook.

Type: int

getPageSizeInch(pageIndex)

Get page size in inch of output image.

ParameterTypeDescription
pageIndexintThe page index is based on zero.

Returns: Page size of image, [0] for width and [1] for height

toImage(filename) (1 of 3)

Render whole workbook as Tiff Image to a file.

ParameterTypeDescription
filenameStringthe filename of the output image

toImage(pageIndex, fileName) (2 of 3)

Render certain page to a file.

ParameterTypeDescription
pageIndexintindicate which page is to be converted
fileNameStringfilename of the output image

toImage(pageIndex, stream) (3 of 3)

Render certain page to a stream.

ParameterTypeDescription
pageIndexintindicate which page is to be converted
streamOutputStreamthe stream of the output image

toPrinter(printerName) (1 of 2)

Render workbook to Printer

ParameterTypeDescription
printerNameStringthe name of the printer , for example: “Microsoft Office Document Image Writer”

toPrinter(printerName, jobName) (2 of 2)

Render workbook to Printer

ParameterTypeDescription
printerNameStringthe name of the printer , for example: “Microsoft Office Document Image Writer”
jobNameStringset the print job name

toImageBytes()

Render whole workbook as Tiff Image to a byte array.

Returns: A byte array.

Example:

import jpype
import asposecells
jpype.startJVM()
from asposecells.api import *

wb = Workbook("Book2.xlsx")
imgOptions = ImageOrPrintOptions()
imgOptions.setHorizontalResolution(200)
imgOptions.setVerticalResolution(300)
imgOptions.setSaveFormat(SaveFormat.XPS)
workbookRender = WorkbookRender(wb, imgOptions)
with open("workbook.xps", "wb") as w:
    content = workbookRender.toImageBytes()
    w.write(content)

jpype.shutdownJVM()