Chart.ToImage causes Exception: Bad State (unknown compression method)

I’m running into an issue when trying to save a Chart as a PNG file to a temp file path. I’ve tried a few different ImageOrPrintOptions with no luck. Other charts are saving fine. Is there something else I need to do?

        var imagePrintOptions = new Aspose.Cells.Rendering.ImageOrPrintOptions
        {
            ImageFormat = ImageFormat.Png,
            ChartImageType = ImageFormat.Png
        };

        c.ToImage(tempImagePath, imagePrintOptions);

Here’s the exception that gets raised:

  •   aexc	{   : Bad state (unknown compression method (0x00))
    
    at .( )
    at .( )
    at .Read(Byte[] , Int32 , Int32 )
    at .Read(Byte[] , Int32 , Int32 )
    at .(Boolean , Boolean , Int32 , Int32 , Int32 , Byte[] , Int32 )
    at .()
    at Aspose.Cells.Drawing.Picture.get_Data()
    at .(Picture )
    at . ( , )
    at . ( , Boolean )
    at .( )
    at . ()
    at . ()
    at .(Stream , Chart )
    at Aspose.Cells.Charts.Chart.ToImage(Stream stream, ImageOrPrintOptions options)
    at Aspose.Cells.Charts.Chart.ToImage(String imageFile, ImageOrPrintOptions options)

@caramanica

Thanks for using Aspose APIs.

Please download and try the most recent version and see if it makes any difference and resolves your issue.

If your issue still occurs, then please provide us your Excel file with problematic chart. We will look into your issue and help you asap.