How to partially convert an Excel Spreadsheet to PDF in Java

Hi Support

I would like to ask about the converting excel file to HTML and Image via gorupdocs JAVA
When I want to convert .xlsx file to image
I able to convert specific sheet with less number of rows less than 1k. but when i try to convert excel sheets having large number of rows 10k or more. am getting error OutOfMemoryError: GC overhead limit exceeded.
i have tried increasing my jvm heap memory up to 4gb still error is there.
i want to try it in diff way is there any mechanism there in groupdocs so we can partially convert sheet. for example if sheet having 10000 rows then i want to convert only 100 rows not all other rows to pdf how can i achive this in GroupDocs Java?

Worksheet ws = worksheets.get(j);
int rowsCount =ws.getCells().getRows().getCount();
if(rowsCount> 100 )
{
ws.getCells().deleteRows(100,rowsCount-100 );
}

i found it in aspose sheets but in groupdocs is it available?
can you please help me out with this?
currently am using evaluation version only for checking out.

Kind regards,
Swapnil

@swapnilkumbhar,

Please skip empty rows and columns using CellsLoadOptions as below:

CellsLoadOptions loadOptions = new CellsLoadOptions();
loadOptions.setSkipEmptyRowsAndColumns(true); 

This may resolve your issue. However, if issue persists, you can share the problematic file with us. We’ll then investigate that.

Currently, API doesn’t provide such feature. We are investigating this. Your investigation ticket ID is CONVERSIONJAVA-746. As we have any further updates, you’ll be notified.

@swapnilkumbhar,

You can convert an Excel sheet by specifying a range using ConvertRange property.
Example: “A1:B3”. Below is the property:

public String getConvertRange();
public void setConvertRange(String value); 

Usage:

CellsLoadOptions loadOptions = new CellsLoadOptions();
loadOptions.setConvertRange("A1:B3"); 

Then use loadOptions as a parameter in convert method along with needed SaveOptions.

ConvertedDocument convertedDocumentPath = conversionHandler.<String> convert(guid, loadOptions, saveOption);

This way you can convert an excel sheet with your desired columns/rows. You can also skip empty rows and columns to get fast results.
We’ve tested this for PDF output and it works perfectly.
Hope it will be helpful for you.