SheetRender
Source: aspose.
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
Parameters
Name | Type | Optional | Description |
---|---|---|---|
worksheet |
|
|
Indicate which spreadsheet to be rendered. |
options |
|
|
ImageOrPrintOptions contains some property of output image |
Methods
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) → Array of float
Get page size in inch of output image.
Parameter
Name | Type | Optional | Description |
---|---|---|---|
pageIndex |
Number |
|
The page index is based on zero. |
- Returns
-
Array of float
Page size of image, [0] for width and [1] for height
toImage(pageIndex, fileName)
Render certain page to a file.
Parameters
Name | Type | Optional | Description |
---|---|---|---|
pageIndex |
Number |
|
indicate which page is to be converted |
fileName |
String |
|
filename of the output image |
toPrinter(printerName)
Render worksheet to Printer
Parameter
Name | Type | Optional | Description |
---|---|---|---|
printerName |
String |
|
the name of the printer , for example: "Microsoft Office Document Image Writer" |
toPrinter(printerName, jobName)
Render worksheet to Printer
Parameters
Name | Type | Optional | Description |
---|---|---|---|
printerName |
String |
|
the name of the printer , for example: "Microsoft Office Document Image Writer" |
jobName |
String |
|
set the print job name |
toImageStream(sheetRender, pageIndex, stream)
Render certain page to a stream.
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);
Parameters
Name | Type | Optional | Description |
---|---|---|---|
sheetRender |
|
The SheetRender object |
|
pageIndex |
Number |
|
Indicate which page is to be converted |
stream |
WritableStream |
|
The stream of the output image |