How to convert first n rows of a XLS/XLSX to JPEG with Aspose.Cells Cloud SDK for Java?

What’s the best way to convert first n rows of a xls/xlsx file to jpeg using Aspose Cells Java SDK?

or

What’s the best way to convert first page(using page break) of a large xls/xlsx file to jpeg using Aspose Cells Java SDK?

@flockfilesharing

Thanks for your inquiry. We are looking into your requirement and will update you shortly.

@flockfilesharing

For your requirement you can use PostPageSetup API Method to set the range for printing and then convert the worksheet to JPEG using GetWorkSheetWithFormat API Method. Please check Java SDK code sample for reference.

File file = new File("C:/Temp/statistics.xlsx");
		String name = "statisticstest.xlsx";
		String folder = null;
		String sheetName = "Sheet1";
		try {
			CellsApi api = new CellsApi("[AppSid]", "[AppKey]");
			//Upload file to storage
			api.uploadFile(name, file, null);
			//Set print area
			PageSetup pageSetup = new PageSetup();
			pageSetup.setPrintArea("B3:K8");
			CellsCloudResponse response = api.cellsPageSetupPostPageSetup(name, sheetName, pageSetup, folder, null);
			//Convert WorkSheet to JPEG
			File outputFile = api.cellsWorksheetsGetWorksheet(name, sheetName, "jpeg", 96, 120, folder, null);
			File dest = new File("C:/Temp/Test.jpeg");
			Files.copy(outputFile.toPath(), dest.toPath(), java.nio.file.StandardCopyOption.REPLACE_EXISTING);
			System.out.print(outputFile.getAbsolutePath());
			// System.out.print("done.....");
			System.out.print("done");
		} catch (ApiException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}