SheetRender.ToImage Fails on Server

I have an issue where I get a “Aspose.Cells.CellsException: Shape to image Error!” when executing on the server (Azure Web App) but not locally. Using 19.2.0 (but also tried with 19.1.0 and 18.12.0). With a sheet that has an ActiveX drop down (see attached). The minimal steps to reproduce would be:

  • create a ASP.Net web project (VS2017)
  • add reference to Aspose.Cells + license
  • add attached file to resources + code similar to below
  • run locally = no error
  • publish to free (or non-free) App Service with default settings = error

Any guidance would be appreciated!!!

site survey - Scratch.zip (84.8 KB)

public class HomeController : Controller
{
public ActionResult Index()
{
return View();
}

    public ActionResult About()
    {
        ViewBag.Message = "Your application description page.";

        //var bitmapGood = CreateImage(new MemoryStream(Properties.Resources.Site_Survey___Good));
        var bitmapTest = CreateImage(new MemoryStream(Properties.Resources.site_survey___Scratch));

        return View();
    }

    public ActionResult Contact()
    {
        ViewBag.Message = "Your contact page.";

        return View();
    }

    private static Bitmap CreateImage(Stream survey)
    {
        // Get worksheet
        Workbook book = new Workbook(survey);
        Worksheet sheet = book.Worksheets[0];

        // Define ImageOrPrintOptions
        ImageOrPrintOptions imgOptions = new ImageOrPrintOptions();
        imgOptions.ImageType = ImageType.Jpeg;
        imgOptions.SetDesiredSize(1632, 2112);
        imgOptions.OnePagePerSheet = true;

        // Render the sheet with respect to specified image/print options
        try
        {
            SheetRender sr = new SheetRender(sheet, imgOptions);
            return sr.ToImage(0);
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
}

@ghitchon,

There are some limitations for GDI+ in Azure Web environment. You may please follow the following thread where similar issue was faced by another user and provide your feedback.

Thanks for the reply. So in this case the solution would be to either remove the offending elements (ActiveX stuff) before creating the image or to change the hosting environment to support GDI+.

@ghitchon,

Yes, you are right. You may opt any of the option which suits to your requirements.