Convert Error! 44920

We use Java Platform!
xls.zip (197.4 KB)
e.cells.zh.a(Unknown Source) com.aspose.cells.zbou.a(Unknown Source) com.aspose.cells.Row.a(Unknown Source) com.aspose.cells.Row.getCellOrNull(Unknown Source) com.aspose.cells.Cells.a(Unknown Source) com.aspose.cells.Cell.a(Unknown Source) com.aspose.cells.Cell.getStyle(Unknown Source) com.aspose.cells.zafs.a(Unknown Source) com.aspose.cells.zafs.b(Unknown Source) com.aspose.cells.zafs.d(Unknown Source) com.aspose.cells.zafs.f(Unknown Source) com.aspose.cells.zafi.a(Unknown Source) com.aspose.cells.zafi.a(Unknown Source) com.aspose.cells.zafi.b(Unknown Source) com.aspose.cells.zafi.a(Unknown Source) com.aspose.cells.zafk.b(Unknown Source) com.aspose.cells.zafg.a(Unknown Source) com.aspose.cells.zafl.a(Unknown Source) com.aspose.cells.Workbook.a(Unknown Source) com.aspose.cells.Workbook.save(Unknown Source)

@landray.com.cn

Please download and try the following fix and let us know your feedback. It should resolve your issue as we have tested it.

It cannot convert and use so many CPU

when we generate thumb of these excel
I found it cost so much time in
at com.aspose.cells.a.d.zgs.a(Unknown Source)
at com.aspose.cells.a.d.zgs.b(Unknown Source)
at com.aspose.cells.a.c.zn.a(Unknown Source)
at com.aspose.cells.zry.a(Unknown Source)
at com.aspose.cells.zry.a(Unknown Source)
at com.aspose.cells.zo.a(Unknown Source)
at com.aspose.cells.zhq.e(Unknown Source)
at com.aspose.cells.zhs.(Unknown Source)
at com.aspose.cells.zat.(Unknown Source)
at com.aspose.cells.zbyx.a(Unknown Source)
at com.aspose.cells.SheetRender.(Unknown Source)
at com.landray.kmss.converter.aspose.AsposeExcelConverter.generateExcelThumbnail(AsposeExcelConverter.java:192)

@landray.com.cn

Please do not use OnePagePerSheet option and try to render your entire worksheet on a single page. There are so many pages in your worksheet. Please see the following screenshot and its highlighted area and comment for help. As you can see in the screenshot, there are 6,000,000 pages which cannot be rendered on a single page.

we did not use OnePagePerSheet

@landray.com.cn

Please provide us your sample code so that we could analyze it and run it at our end and replicate this issue. Please make sure, you provide the runnable code and it does not have any compile-time errors. It should be simplified as well. Thanks for your cooperation in this regard and have a good day.

Workbook workbook = new Workbook(System.getProperty(“user.dir”) + File.separator + “tst.xls”);
int activeIndex = workbook.getWorksheets().getActiveSheetIndex();
Worksheet sheetActive = workbook.getWorksheets().get(activeIndex);
ImageOrPrintOptions imgOption = new ImageOrPrintOptions();
imgOption.setHorizontalResolution(96);
imgOption.setVerticalResolution(96);
imgOption.setDefaultFont(“SimSun”);
imgOption.setQuality(100);
OutputStream thumbnailSrcOutput = new FileOutputStream(
System.getProperty(“user.dir”) + File.separator + “tst.png”);
SheetRender sheetRender = new SheetRender(sheetActive, imgOption);
sheetRender.toImage(0, thumbnailSrcOutput);

@landray.com.cn

We were able to observe this issue but we need to look into it further. We will look into this issue more and update you asap.

@landray.com.cn

Thanks for considering Aspose APIs.

We have replicated and logged your issues as

  • CELLSJAVA-42424 - Exception in thread “main” java.lang.OutOfMemoryError: GC overhead limit exceeded - File I
  • CELLSJAVA-42425 - Exception in thread “main” java.lang.OutOfMemoryError: GC overhead limit exceeded - File II
  • CELLSJAVA-42426 - Exception in thread “main” java.lang.OutOfMemoryError: GC overhead limit exceeded - File III

@landray.com.cn

Take your file for example “支付组件V1.2.4.06261版本测试报告.xlsx”, other files are also similar.

There is some statistics data in the range ZZ999953:AAB999960, this causes the sheet to have more than 3,000,000 pages. Too many pages cause the OOM exception while Aspose.Cells is collecting page infos.

As a workaround, please set the print area to the actual data area A1:I4, then convert the sheet to image. It will then fix your issue.

how to set?

we hope you to give us example code to generate excel thumbnail by avoiding OOM,and also generate html by avoiding OOM!

@landray.com.cn

Please see the following code, it sets the print area of the worksheet.

Java

//Set print area of worksheet
sheetActive.getPageSetup().setPrintArea("A1:I4");

Screenshot

we hope you to give us example code to generate excel thumbnail by avoiding OOM,and also generate html by avoiding OOM!

other words:we hope you to optimize this code:
Workbook workbook = new Workbook(System.getProperty(“user.dir”) + File.separator + “tst.xls”);
int activeIndex = workbook.getWorksheets().getActiveSheetIndex();
Worksheet sheetActive = workbook.getWorksheets().get(activeIndex);
ImageOrPrintOptions imgOption = new ImageOrPrintOptions();
imgOption.setHorizontalResolution(96);
imgOption.setVerticalResolution(96);
imgOption.setDefaultFont(“SimSun”);
imgOption.setQuality(100);
OutputStream thumbnailSrcOutput = new FileOutputStream(
System.getProperty(“user.dir”) + File.separator + “tst.png”);
SheetRender sheetRender = new SheetRender(sheetActive, imgOption);
sheetRender.toImage(0, thumbnailSrcOutput);

when we use
image.png (35.2 KB)
cells.applyStyle
it throw exceptions below:
Caused by:java.lang.ArrayIndexOutOfBoundsException: 191 com.aspose.cells.zcab.b(Unknown Source) com.aspose.cells.zcab.a(Unknown Source) com.aspose.cells.zhc.(Unknown Source) com.aspose.cells.WorksheetCollection.a(Unknown Source) com.aspose.cells.zafv.(Unknown Source) com.aspose.cells.Workbook.a(Unknown Source) com.aspose.cells.Workbook.save(Unknown Source

when we use cells.applyStyle,it throws exceptions

Caused by:java.lang.ArrayIndexOutOfBoundsException: 191 com.aspose.cells.zcab.b(Unknown Source) com.aspose.cells.zcab.a(Unknown Source) com.aspose.cells.zhc.(Unknown Source) com.aspose.cells.WorksheetCollection.a(Unknown Source) com.aspose.cells.zafv.(Unknown Source) com.aspose.cells.Workbook.a(Unknown Source) com.aspose.cells.Workbook.save(Unknown Source

@landray.com.cn

Please see the following code and its comment. Please see the image generated by the code for your reference. As you can see, only the area surrounded by Yellow fill color (i.e. “A8:J23”) is printed on the image.

You need to do such changes in your code to fix your issue. You must first set the print area and then take the image. This will avoid OOM issue.

Download Link:
Sample Excel File.zip (7.8 KB)

Java

Workbook workbook = new Workbook(dirPath + "sample.xlsx");
int activeIndex = workbook.getWorksheets().getActiveSheetIndex();
Worksheet sheetActive = workbook.getWorksheets().get(activeIndex);

//Set print area of worksheet
sheetActive.getPageSetup().setPrintArea("A8:J23");

ImageOrPrintOptions imgOption = new ImageOrPrintOptions();
imgOption.setHorizontalResolution(96);
imgOption.setVerticalResolution(96);
imgOption.setDefaultFont("SimSun");
imgOption.setQuality(100);

OutputStream thumbnailSrcOutput = new FileOutputStream(dirPath + "tst.png");

SheetRender sheetRender = new SheetRender(sheetActive, imgOption);
sheetRender.toImage(0, thumbnailSrcOutput);

Output Image:

@landray.com.cn

We tested this issue with the following sample code and it works fine. If you find any issue, please provide us your sample Excel file and your runnable sample code that throws this exception.

Download Link:
Output Excel File.zip (5.6 KB)

Java

Workbook excel = new Workbook();

Worksheet worksheet = excel.getWorksheets().get(0);
worksheet.getCells().get("E9").putValue("This is a simple text.");

Style newStyle = excel.createStyle();
newStyle.setTextWrapped(true);

StyleFlag flag = new StyleFlag();
flag.setWrapText(true);

Cells cells = worksheet.getCells();
cells.applyStyle(newStyle, flag);

excel.save(dirPath + "outputWrapText.xlsx");

Screenshot

@landray.com.cn

To meet your needs, we have added a New Feature request in our database. Once, it will be implemented, you will be able to get the thumbnail of any page you like easily without any memory issues.

The New Feature request has been logged as

  • CELLSJAVA-42433 - ImageOrPrintOptions.PageIndex and ImageOrPrintOptions.Count properties needed to get the image of desired pages

@landray.com.cn

Thanks for using Aspose APIs.

This is to inform you that we have fixed your issues now. We will soon provide the fix after performing QA and including other enhancements and fixes.

@landray.com.cn

Thanks for using Aspose APIs.

Please download and try the following fix and let us know your feedback.


We added API: ImageOrPrintOptions.PageIndex and ImageOrPrintOptions.PageCount.

Code:

Workbook workbook = new Workbook(System.getProperty(“user.dir”) + File.separator + “tst.xls”); 
int activeIndex = workbook.getWorksheets().getActiveSheetIndex(); 
Worksheet sheetActive = workbook.getWorksheets().get(activeIndex); 
ImageOrPrintOptions imgOption = new ImageOrPrintOptions(); 
imgOption.setHorizontalResolution(96); 
imgOption.setVerticalResolution(96); 
imgOption.setDefaultFont(“SimSun”); 
imgOption.setQuality(100); 

imgOption.setPageIndex(0); 
imgOption.setPageCount(1); 

OutputStream thumbnailSrcOutput = new FileOutputStream( 
System.getProperty(“user.dir”) + File.separator + “tst.png”); 
SheetRender sheetRender = new SheetRender(sheetActive, imgOption); 
sheetRender.toImage(0, thumbnailSrcOutput);