Saving a Workbook as PDF produces a CellsException



We are receiving a CellsException when we try to convert a workbook to a PDF file.

Although the CellsException doesn’t happen for all Workbooks, the exception is typically incurred when:

  1. There is an embedded chart within a worksheet.
  2. The Worsheet.removeUnusedStyles API is invoked.

The exception can be reproduced using the latest Aspose Cells version 17.10, the attached “WorkbookToPdf.xlsx” file and the following code:

  try {
     // provide full path to Workbook file
     String fileName = "WorkbookToPdf.xlsx"; 
     Workbook wb = new Workbook(fileName);
     PdfSaveOptions saveOpts = new PdfSaveOptions(SaveFormat.PDF);
     fileName = fileName.replace(".xlsx", "_aspose.pdf");

     // NOTE: Commenting the following line circumvents the CellsException
     wb.removeUnusedStyles();, saveOpts);
  } catch (Exception ex) {
     System.out.println("Unexpected EXCEPTION: \n\t"  + ex.getMessage());

As noted in the code comment, we’ve observed that avoiding the invocation to the ‘removeUnusedStyles’ API, circumvents the issue. However, we require that this API be invoked.

Thanks. (11.7 KB)



Thanks for your posting and using Aspose APIs.

We were able to observe this issue as per your description using the following code and found saving workbook as PDF after removeUnusedStyles API produces a CellsException.

We have logged this issue in our database for investigation. We will look into it and fix this issue. Once, the issue is resolved or we have some other news for you, we will let you know asap.

This issue has been logged as

  • CELLSJAVA-42452 - Saving a Workbook as PDF after RemoveUnusedStyles API produces a CellsException


Workbook wb = new Workbook(dirPath + "WorkbookToPdf.xlsx");
//This line is important to produce exception
wb.removeUnusedStyles(); + "out.pdf");


Exception in thread "main" com.aspose.cells.CellsException
	at com.aspose.cells.zbyt.a(Unknown Source)
	at com.aspose.cells.zbyt.a(Unknown Source)
	at com.aspose.cells.Workbook.a(Unknown Source)
	at Source)
	at Source)
	at ClsAsposeCells.f1(
	at ClsAsposeCells.main(



Thanks for using Aspose APIs.

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


The issues you have found earlier (filed as CELLSJAVA-42452) have been fixed in this Aspose.Cells for Java 17.11 update.

Please also check the following document/blog for your reference: