WorkbookRender
Contents
[
Hide
]WorkbookRender class
Represents a Workbook render. The constructor of this class , must be used after modification of pagesetup, cell style.
Constructors
| Name | Description |
|---|---|
| WorkbookRender | The construct of WorkbookRender |
Properties
| Name | Type | Description |
|---|---|---|
| PageCount | int | Gets the total page count of workbook. |
Methods
| Name | Description |
|---|---|
| getPageSizeInch | Get page size in inch of output image. |
| toImage | Render whole workbook as Tiff Image to a file. |
| toPrinter | Render workbook to Printer |
| toImageBytes | Render whole workbook as Tiff Image to a byte array. |
WorkbookRender(workbook, options)
The construct of WorkbookRender
| Parameter | Type | Description |
|---|---|---|
| workbook | Workbook | Indicate which workbook to be rendered. |
| options | ImageOrPrintOptions | ImageOrPrintOptions 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.
| Parameter | Type | Description |
|---|---|---|
| pageIndex | int | The 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.
| Parameter | Type | Description |
|---|---|---|
| filename | String | the filename of the output image |
toImage(pageIndex, fileName) (2 of 3)
Render certain page to a file.
| Parameter | Type | Description |
|---|---|---|
| pageIndex | int | indicate which page is to be converted |
| fileName | String | filename of the output image |
toImage(pageIndex, stream) (3 of 3)
Render certain page to a stream.
| Parameter | Type | Description |
|---|---|---|
| pageIndex | int | indicate which page is to be converted |
| stream | OutputStream | the stream of the output image |
toPrinter(printerName) (1 of 2)
Render workbook to Printer
| Parameter | Type | Description |
|---|---|---|
| printerName | String | the name of the printer , for example: “Microsoft Office Document Image Writer” |
toPrinter(printerName, jobName) (2 of 2)
Render workbook to Printer
| Parameter | Type | Description |
|---|---|---|
| printerName | String | the name of the printer , for example: “Microsoft Office Document Image Writer” |
| jobName | String | set 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()