SheetRender

SheetRender class

Represents a worksheet render which can render worksheet to various images such as (BMP, PNG, JPEG, TIFF..) The constructor of this class , must be used after modification of pagesetup, cell style.

new SheetRender(worksheet, options)

the construct of SheetRender, need worksheet and ImageOrPrintOptions as params

Methods

NameDescription
getPageCount()Gets the total page count of current worksheet.
getPageScale()Gets calculated page scale of the sheet. Returns the set scale if PageSetup.Zoom is set. Otherwise, returns the calculat
getPageSizeInch(pageIndex)Get page size in inch of output image.
toImage(pageIndex, fileName)Render certain page to a file.
toPrinter(printerName)Render worksheet to Printer
toPrinter(printerName, jobName)Render worksheet to Printer
toImageStream(sheetRender, pageIndex, stream) (static)Render certain page to a stream.

getPageCount()

Gets the total page count of current worksheet.

getPageScale()

Gets calculated page scale of the sheet. Returns the set scale if PageSetup.Zoom is set. Otherwise, returns the calculated scale according to PageSetup.FitToPagesWide and PageSetup.FitToPagesTall.

getPageSizeInch(pageIndex)

Get page size in inch of output image.

ParameterTypeDescription
pageIndexNumberThe page index is based on zero.

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

toImage(pageIndex, fileName)

Render certain page to a file.

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

toPrinter(printerName)

Render worksheet to Printer

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

toPrinter(printerName, jobName)

Render worksheet to Printer

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

toImageStream(sheetRender, pageIndex, stream) (static)

Render certain page to a stream.

ParameterTypeDescription
sheetRenderSheetRenderThe SheetRender object
pageIndexNumberIndicate which page is to be converted
streamWritableStreamThe stream of the output image

Example:

var aspose = aspose || {};
aspose.cells = require("aspose.cells");
var fs = require("fs");
var workbook = new aspose.cells.Workbook("Book2.xlsx");
var imgOptions = new aspose.cells.ImageOrPrintOptions();
imgOptions.setHorizontalResolution(200);
imgOptions.setVerticalResolution(300);
imgOptions.setImageFormat(aspose.cells.ImageFormat.getJpeg());
var worksheet = workbook.getWorksheets().get(0);
var sheetRender = new aspose.cells.SheetRender(worksheet, imgOptions);
var imgWriteStream = fs.createWriteStream("sheet1.jpeg");
aspose.cells.SheetRender.toImageStream(sheetRender, 0, imgWriteStream);