One Excel worksheet conversion fails with "Unable to cast .." error

For archiving purposes, I’m trying to convert the attached test_chart.xlsx to PDF:

        // Open the template excel file
        Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(inputPath);

        // create explicit SaveOptions
        Aspose.Cells.PdfSaveOptions pdfSaveOptions = new Aspose.Cells.PdfSaveOptions();
        pdfSaveOptions.OnePagePerSheet = true;
        pdfSaveOptions.AllColumnsInOnePagePerSheet = true;
        pdfSaveOptions.ExportDocumentStructure = true;
        pdfSaveOptions.GridlineType = GridlineType.Hair;

        foreach (Worksheet worksheet in wb.Worksheets)
        {
            worksheet.PageSetup.PrintGridlines = false;
        }

        // Save the pdf file.
        wb.Save(outputPath, pdfSaveOptions);

But this fails with error: Unable to cast object of type ‘???’ to type ‘???’.
I use Aspose libraries version 22.2.

Test_chart.zip (8.5 KB)

@fransbloemen,

Thanks for the template file.

Please notice, I am able to reproduce the issue as you mentioned by using your template file. I found an exception when your Excel spreadsheet conversion is failed. It looks like your issue might be due to the fact that the last two worksheets in your Excel file are blank. Anyways, I have logged a ticket with an id “CELLSNET-50946” for your issue. We will look into it soon.

Once we have an update on it, we will let you know.

@fransbloemen,

We are pleased to inform you that your issue has been resolved now. The fix will be included in (upcoming) next release (Aspose.Cells for .NET v22.5) which is scheduled to be released in the second week of May 2022. You will also be notified when the next version is released.

Please note, the issue only occurs in evaluation mode (i.e., without using a valid license). So, as a workaround, you can set a valid license in code (at the beginning and prior using any other Aspose.Cells APIs) before the next release is released.

The issues you have found earlier (filed as CELLSNET-50946) have been fixed in this update. This message was posted using Bugs notification tool by johnson.shi