We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How to specify page dimensions to a worksheet renderer while retrieving page wise images of a worksheet


I am using Aspose.Cells v8.5.2.4
We are generating images of all pages in each worksheet via code :
Workbook workbook = getWorkbook(sourcePath);
WorksheetCollection worksheetCollection = workbook.getWorksheets();

ImageOrPrintOptions imageOrPrintOptions = …

for (int i = 0; i < worksheetCollection.getCount(); i++) {
Worksheet worksheet = worksheetCollection.get(i);
SheetRender sr = new SheetRender(worksheet, imageOrPrintOptions);
for (int j = 0; j < sr.getPageCount() ; j++) {
String imageFilePath = …;
sr.toImage(j, imageFilePath);

I would like to know is there any option where we can define the dimension of pages in a worksheet.
As for the attached Excel document, the images of the pages in worksheet 1.4 Work Item.Area Hierarchy are difficult to understand and we might want to make one worksheet = 2 pages or something like defining to break a worksheet into four equal dimension pages etc…


Hi Jaspreet,

Thank you for contacting Aspose support.

What I understand from your problem description is that you wish to split the worksheet into several pages regardless of the predefined page breaks. First of all, please note that worksheets are split according to the automatic page breaks that in turn depends on the paper size set in the Page Setup of the particular spreadsheet. Therefore when you render the worksheet using the SheetRender class with default settings, the pages are automatically split. This behavior is similar to Print Preview of Excel application, that mean; the worksheet should be split as shown in Print Preview of Excel application, without any special settings. This behavior can be override to some extent while using the custom page breaks or you may also try rendering a specific range, if it fits your requirement.

On another note, if you wish to control the size (dimensions in height & width) of the resultant image, you may employ the ImageOrPrintOptions.setDesiredSize method to achieve that.

Hope this helps a bit.