public class SheetRender
extends java.lang.Object
| Constructor and Description |
|---|
SheetRender(Worksheet worksheet,
ImageOrPrintOptions options)
the construct of SheetRender, need worksheet and ImageOrPrintOptions as params
|
| Modifier and Type | Method and Description |
|---|---|
void |
dispose()
Releases resources created and used for rendering.
|
int |
getPageCount()
Gets the total page count of current worksheet.
|
double |
getPageScale()
Gets calculated page scale of the sheet.
|
float[] |
getPageSizeInch(int pageIndex)
Get page size in inch of output image.
|
void |
toImage(int pageIndex,
java.io.InputStream stream)
Render certain page to a stream.
|
void |
toImage(int pageIndex,
java.io.OutputStream stream)
Render certain page to a stream.
|
void |
toImage(int pageIndex,
java.lang.String fileName)
Render certain page to a file.
|
void |
toPrinter(java.lang.String printerName)
Render worksheet to Printer
|
void |
toPrinter(java.lang.String printerName,
int printPageIndex,
int printPageCount)
Deprecated.
Use ToPrinter(string PrinterName) and ImageOrPrintOptions.PageIndex, PageCount instead.
|
void |
toPrinter(java.lang.String printerName,
java.lang.String jobName)
Render worksheet to Printer
|
void |
toTiff(java.io.InputStream stream)
Render whole worksheet as Tiff Image to stream.
|
public SheetRender(Worksheet worksheet, ImageOrPrintOptions options)
worksheet - Indicate which spreadsheet to be rendered.options - ImageOrPrintOptions contains some property of output imagepublic int getPageCount()
public double getPageScale()
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();
public float[] getPageSizeInch(int pageIndex)
pageIndex - The page index is based on zero.public void toImage(int pageIndex,
java.lang.String fileName)
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");
pageIndex - indicate which page is to be convertedfileName - filename of the output imagepublic void toImage(int pageIndex,
java.io.InputStream stream)
pageIndex - indicate which page is to be convertedstream - the stream of the output imagepublic void toImage(int pageIndex,
java.io.OutputStream stream)
pageIndex - indicate which page is to be convertedstream - the stream of the output imagepublic void toTiff(java.io.InputStream stream)
stream - the stream of the output imagepublic void toPrinter(java.lang.String printerName)
printerName - the name of the printer , for example: "Microsoft Office Document Image Writer"public void toPrinter(java.lang.String printerName,
java.lang.String jobName)
printerName - the name of the printer , for example: "Microsoft Office Document Image Writer"jobName - set the print job namepublic void toPrinter(java.lang.String printerName,
int printPageIndex,
int printPageCount)
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.printerName - the name of the printer , for example: "Microsoft Office Document Image Writer"printPageIndex - the 0-based index of the first page to print, it must be in Range [0, SheetRender.PageCount-1]printPageCount - the number of pages to print, it must be greater than zeropublic void dispose()
See Also:
Aspose.Cells Documentation - the home page for the Aspose.Cells Product Documentation.
Aspose.Cells Support Forum - our preferred method of support.
We guarantee a prompt response to any inquiry!
© Aspose Pty Ltd 2003-2025. All Rights Reserved.