I am generating image of excel sheet using aspose.cells and it is working fine but when I try to generate excel file containing 4 sheets and bulk amount of data in them it produces an error
OutOfHeapMemory
And if I put condition than it reads that excel which has less data like this-
Workbook workbook = new Workbook(sourceDir);
List<Worksheet> worksheets = getAllWorksheets(workbook);
if (worksheets != null) {
int noOfImages = 0;
for (Worksheet worksheet : worksheets) {
if (worksheet.getCells().getCount() > 0 || worksheet.getCharts().getCount() > 0 || worksheet.getPictures().getCount() > 0) {
System.out.println("Worksheet Before Condition" + worksheet);
if (worksheet.getCells().getCount() < 2000) {
System.out.println("Worksheet After Condition" + worksheet);
String imageFilePath = workingDir + File.separator + projectName + File.separator + fileName + "_" + (noOfImages++) + ".png";
SheetRender sr = new SheetRender(worksheet, getImageOrPrintOptions());
sr.toImage(0, imageFilePath);
}
}
}
}
I have used System.out.println before and after if condition to check the worksheets that are iterating in loop.
Worksheet Before ConditionAspose.Cells.Worksheet[ Details of Indian Companies Reg ]
Worksheet Before ConditionAspose.Cells.Worksheet[ LLP'S Incorporated in Jun ]
Worksheet Before ConditionAspose.Cells.Worksheet[ Foreign Companies Registered ]
Worksheet After ConditionAspose.Cells.Worksheet[ Foreign Companies Registered ]