SheetRender
Inheritance: java.lang.Object
public 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.
Constructors
Constructor | Description |
---|---|
SheetRender(Worksheet worksheet, ImageOrPrintOptions options) | the construct of SheetRender, need worksheet and ImageOrPrintOptions as params |
Methods
Method | Description |
---|---|
dispose() | Releases resources created and used for rendering. |
equals(Object arg0) | |
getClass() | |
getPageCount() | Gets the total page count of current worksheet. |
getPageScale() | Gets calculated page scale of the sheet. |
getPageSizeInch(int pageIndex) | Get page size in inch of output image. |
hashCode() | |
notify() | |
notifyAll() | |
toImage(int pageIndex, InputStream stream) | Render certain page to a stream. |
toImage(int pageIndex, OutputStream stream) | Render certain page to a stream. |
toImage(int pageIndex, String fileName) | Render certain page to a file. |
toPrinter(String printerName) | Render worksheet to Printer |
toPrinter(String printerName, int printPageIndex, int printPageCount) | Render worksheet to Printer |
toPrinter(String printerName, String jobName) | Render worksheet to Printer |
toString() | |
toTiff(InputStream stream) | Render whole worksheet as Tiff Image to stream. |
wait() | |
wait(long arg0) | |
wait(long arg0, int arg1) |
SheetRender(Worksheet worksheet, ImageOrPrintOptions options)
public SheetRender(Worksheet worksheet, ImageOrPrintOptions options)
the construct of SheetRender, need worksheet and ImageOrPrintOptions as params
Parameters:
Parameter | Type | Description |
---|---|---|
worksheet | Worksheet | Indicate which spreadsheet to be rendered. |
options | ImageOrPrintOptions | ImageOrPrintOptions contains some property of output image |
dispose()
public void dispose()
Releases resources created and used for rendering.
equals(Object arg0)
public boolean equals(Object arg0)
Parameters:
Parameter | Type | Description |
---|---|---|
arg0 | java.lang.Object |
Returns: boolean
getClass()
public final native Class<?> getClass()
Returns: java.lang.Class
getPageCount()
public int getPageCount()
Gets the total page count of current worksheet.
Returns: int
getPageScale()
public double getPageScale()
Gets calculated page scale of the sheet. Returns the set scale if PageSetup.getZoom() is set. Otherwise, returns the calculated scale according to PageSetup.getFitToPagesWide() and PageSetup.getFitToPagesTall().
Example
Workbook wb = new Workbook("Book1.xlsx");
SheetRender sheetRender = new SheetRender(wb.getWorksheets().get(0), new ImageOrPrintOptions());
//Gets calculated page scale of the sheet.
double pageScale = sheetRender.getPageScale();
Returns: double
getPageSizeInch(int pageIndex)
public float[] getPageSizeInch(int pageIndex)
Get page size in inch of output image.
Parameters:
Parameter | Type | Description |
---|---|---|
pageIndex | int | The page index is based on zero. |
Returns: float[] - Page size of image, [0] for width and [1] for height
hashCode()
public native int hashCode()
Returns: int
notify()
public final native void notify()
notifyAll()
public final native void notifyAll()
toImage(int pageIndex, InputStream stream)
public void toImage(int pageIndex, InputStream stream)
Render certain page to a stream.
Parameters:
Parameter | Type | Description |
---|---|---|
pageIndex | int | indicate which page is to be converted |
stream | java.io.InputStream | the stream of the output image |
toImage(int pageIndex, OutputStream stream)
public void toImage(int pageIndex, OutputStream stream)
Render certain page to a stream.
Parameters:
Parameter | Type | Description |
---|---|---|
pageIndex | int | indicate which page is to be converted |
stream | java.io.OutputStream | the stream of the output image |
toImage(int pageIndex, String fileName)
public void toImage(int pageIndex, String fileName)
Render certain page to a file.
Example
The following code outputs the first page of the first sheet to png image.
//load the source file with images.
Workbook wb = new Workbook("Book1.xlsx");
ImageOrPrintOptions imgOpt = new ImageOrPrintOptions();
//set output image type.
imgOpt.setImageType(ImageType.PNG);
//render the first sheet.
SheetRender sr = new SheetRender(wb.getWorksheets().get(0), imgOpt);
//output the first page of the sheet to image.
sr.toImage(0, "output.png");
Parameters:
Parameter | Type | Description |
---|---|---|
pageIndex | int | indicate which page is to be converted |
fileName | java.lang.String | filename of the output image |
toPrinter(String printerName)
public void toPrinter(String printerName)
Render worksheet to Printer
Parameters:
Parameter | Type | Description |
---|---|---|
printerName | java.lang.String | the name of the printer , for example: “Microsoft Office Document Image Writer” |
toPrinter(String printerName, int printPageIndex, int printPageCount)
public void toPrinter(String printerName, int printPageIndex, int printPageCount)
Render worksheet to Printer
Remarks
NOTE: This method is now obsolete. Instead, please use ToPrinter(string PrinterName) and ImageOrPrintOptions.PageIndex, PageCount to set the first page and the number of pages to print. This property will be removed 12 months later since December 2021. Aspose apologizes for any inconvenience you may have experienced.
Parameters:
Parameter | Type | Description |
---|---|---|
printerName | java.lang.String | the name of the printer , for example: “Microsoft Office Document Image Writer” |
printPageIndex | int | the 0-based index of the first page to print, it must be in Range [0, SheetRender.PageCount-1] |
printPageCount | int | the number of pages to print, it must be greater than zero |
toPrinter(String printerName, String jobName)
public void toPrinter(String printerName, String jobName)
Render worksheet to Printer
Parameters:
Parameter | Type | Description |
---|---|---|
printerName | java.lang.String | the name of the printer , for example: “Microsoft Office Document Image Writer” |
jobName | java.lang.String | set the print job name |
toString()
public String toString()
Returns: java.lang.String
toTiff(InputStream stream)
public void toTiff(InputStream stream)
Render whole worksheet as Tiff Image to stream.
Parameters:
Parameter | Type | Description |
---|---|---|
stream | java.io.InputStream | the stream of the output image |
wait()
public final void wait()
wait(long arg0)
public final native void wait(long arg0)
Parameters:
Parameter | Type | Description |
---|---|---|
arg0 | long |
wait(long arg0, int arg1)
public final void wait(long arg0, int arg1)
Parameters:
Parameter | Type | Description |
---|---|---|
arg0 | long | |
arg1 | int |