Issues converting Excels to PDF


Using the following code:

        try {

            Workbook workbook = new Workbook(filePath);
            PdfSaveOptions opts = new PdfSaveOptions();
   + ".pdf", opts);
        } catch (Exception e) {
            System.out.println("Exception:\n"+ e.toString());

On the following 4 files, I get the following 4 exceptions:

com.aspose.cells.CellsException: 1

com.aspose.cells.CellsException: 1

com.aspose.cells.CellsException: Column width must be between 0 and 255

java.lang.OutOfMemoryError: Java heap space


I have tried your first three files with the latest version but could not observe any issue.
Please try our latest version/fix: Aspose.Cells for Java v19.7.6 (attached) (6.6 MB)

Regarding the Java heap size issue for “20150126 - D1 Ownership.xlsx”, we were able to observe the issue but we need to look into it more. We have logged the issue in our database for investigation and for a fix. Once, we will have some news for you, we will update you in this topic.

This issue has been logged as

CELLSJAVA-42981 – Exception "Java.lang.OutOfMemoryError: Java heap space" while converting to PDF



We evaluated your issue further.
Well, your issue is because there are more than 80 million pages (lots of blank pages in it) in worksheet “Officers, Jurisdiction & Voting”. You can try using the following code to set print area that with data:

Workbook wb = new Workbook("20150126 - D1 Ownership.xlsx");

Worksheet sheet = wb.getWorksheets().get("Officers, Jurisdiction & Voting");
String maxDataCellName = CellsHelper.cellIndexToName(sheet.getCells().getMaxDataRow(), sheet.getCells().getMaxDataColumn());

Another way is by skipping the files which contain too many pages. We will provide new API to evaluate the total pages of file before saving to PDF file format.



We add new APIs: WorkbookPrintingPreview.getEvaluatedPageCount() and SheetPrintingPreview.getEvaluatedPageCount() to get page count efficiently in the upcoming fix/version (we will share the Download link to the fix in the next few days or so).
Sample code:

Workbook wb = new Workbook("20150126 - D1 Ownership.xlsx");
ImageOrPrintOptions imgOpt = new ImageOrPrintOptions();

WorkbookPrintingPreview wp = new WorkbookPrintingPreview(wb, imgOpt);

SheetPrintingPreview sp = new SheetPrintingPreview(wb.getWorksheets().get("Officers, Jurisdiction & Voting"), imgOpt);