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

Free Support Forum - aspose.com

Fit sheet on one page

Hi,
how do we render a worksheet on a single A4 page with aspose-cells for java 17-9?

	ImageOrPrintOptions options = new ImageOrPrintOptions();
	options.setImageFormat(ImageFormat.getJpeg());
	options.setOnePagePerSheet(true);
	options.setHorizontalResolution(120);
	options.setVerticalResolution(120);
	options.setOutputBlankPageWhenNothingToPrint(false);
	
	worksheet.getPageSetup().setPaperSize(PaperSizeType.PAPER_A_4);
	worksheet.getPageSetup().setPercentScale(false);
	worksheet.getPageSetup().setFitToPages(1,1);
	SheetRender sr = new SheetRender(worksheet, options);	
	sr.toImage(0, "c:/temp/xls.jpg");

testexcel.zip (13.6 KB)

@josef.auer1,

Thanks for providing us template file.

Please remove or comment out the following line of code as it is not needed:
e.g
Sample code:

.........
options.setOnePagePerSheet(true); 
..........

When you use the above line, it will ignore Page Setup options you set.

Hope, this helps a bit.