Can not able to save with workbook.save when there are 10000+ columns which have filters. Also it takes a lots of RAM uses

Hi,

I am trying to convert an excel file into pdf with the below-metioned implementation. But when workbook.save(path, saveoptions) function execute, it takes a lot of time and RAM.
// code
Workbook workbook = new Workbook(file.getAbsolutePath());
workbook.save(outputFilePath, new PdfSaveOptions());

Here I also provide a sample xlsx file in which I am facing issue.
Sample xlsx: FA_Umlaut_ä OFFE 20210610 xxx.xlsx - Google Drive

Thanks in advance,
Arth Soni.

@staunctest,
We have observed this issue and logged it in our database for further investigation. We will write back here once any update is ready for sharing.

This issue is logged as:
CELLSJAVA-43517 - Conversion to PDF fails due to out of memory error

@staunctest,

Your issue is due to lots of (unnecessary) blank filters set on huge list of columns. This would only eat resource (RAM, CPU) and render/add lots of unnecessary blank pages to the output. We recommend you to kindly add the following two lines (in bold) to your code, it will work fine and efficiently:
e.g.
Sample code:

Workbook workbook = new Workbook(file.getAbsolutePath());
workbook.getWorksheets().get(0).getCells().deleteBlankRows();
workbook.getWorksheets().get(0).getCells().deleteBlankColumns();
workbook.save(outputFilePath, new PdfSaveOptions());

I have tested the above lines using your template file and it takes a few seconds only.

Let us know if it works for your needs.

Hi Amjad_Sahi,

I tested your provided solution and it is working in my case. Now for me, it is also converted in few seconds.

Thank you,
Arth Soni.

@staunctest,

That is great. Sure, you may use this workaround for your needs. You should not render all those blank and unnecessary pages for no benefit, which will consequently consume resources and would create huge sized PDF (if the process is completed).

Yes, that’s right.