aspose.cells

Class SheetRender

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.

Constructor Summary
SheetRender(worksheet, options)
the construct of SheetRender, need worksheet and ImageOrPrintOptions as params
 
Property Getters/Setters Summary
functiongetPageCount()
function
           Indicate the total page count of current worksheet
functiongetPageScale()
Gets calculated page scale of the sheet.
 
Method Summary
functiongetPageSize(pageIndex)
Get page size of output image. The size unit is in point.
functiontoImage(pageIndex, fileName)
Render certain page to a file.
static functiontoImageStream(sheetRender, pageIndex, stream)
Render certain page to a stream.
functiontoPrinter(PrinterName)
Render worksheet to Printer
functiontoPrinter(PrinterName, DocumentName)
Render worksheet to Printer
 

    • Constructor Detail

      • SheetRender

        function SheetRender(worksheet, options)
        the construct of SheetRender, need worksheet and ImageOrPrintOptions as params
        Parameters:
        worksheet: Worksheet - Indicate which spreadsheet to be rendered.
        options: ImageOrPrintOptions - ImageOrPrintOptions contains some property of output image
    • Property Getters/Setters Detail

      • getPageCount/setPageCount : Number 

        function getPageCount() / function setPageCount(value)
        
        Indicate the total page count of current worksheet
      • getPageScale : Number 

        function getPageScale()
        
        Gets calculated page scale of the sheet.
        Returns:
    • Method Detail

      • getPageSize

        function getPageSize(pageIndex)
        Get page size of output image. The size unit is in point.
        Parameters:
        pageIndex: Number - The page index is based on zero.
        Returns:
        Page size of image, [0] for width and [1] for height
      • toImage

        function toImage(pageIndex, fileName)
        Render certain page to a file.
        Parameters:
        pageIndex: Number - indicate which page is to be converted
        fileName: String - filename of the output image
      • toPrinter

        function toPrinter(PrinterName)
        Render worksheet to Printer
        Parameters:
        PrinterName: String - the name of the printer , for example: "Microsoft Office Document Image Writer"
      • toPrinter

        function toPrinter(PrinterName, DocumentName)
        Render worksheet to Printer
        Parameters:
        PrinterName: String - the name of the printer , for example: "Microsoft Office Document Image Writer"
        DocumentName: String - set the print job name
      • toImageStream

        static function toImageStream(sheetRender, pageIndex, stream)
        Render certain page to a stream.
        Parameters:
        sheetRender: SheetRender - The SheetRender object
        pageIndex: Number - Indicate which page is to be converted
        stream: WritableStream - The 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);