Open niclasbb opened 1 year ago
Are you using the latest version of EPPlus?
Yes, version 6.1.3
Looks like a missing GDI issue. Are you using the free tier in Azure?
No - Standard S3 Plan ( 4 vCPU and 7 GB Memory)
Does the workbooks open correctly if you run EPPlus locally?
Yes - everything works perfect locally and on-premise servers. But crashes direct in Azure App Service (Windows Plan - .Net Framework).
If we remove the picture from the worksheet it works as well.
It likely crashes here...
https://github.com/EPPlusSoftware/EPPlus/blob/c61adffbfb19313b8135eef6c5e12f13d52a0451/src/EPPlus/Drawing/ImageHandling/GenericImageHandler.cs#L57
It's weird as it should catch the Exception and use the build in image handler. Also, if you use Windows it should have GDI available.
Is this your setting:
Do you have a more detailed stack trace of the error?
Yes that is the correct setting.
This is the file with the image causing the error. I have tried with some other images and this is the only one that fails. Maybe there is a problem with this image?
This is an EMF image. I wonder if Azure's GDI implementation does not support EMF's. I will try to see if I can replicate this issue. We have a build in handler for all image types, but it seems that it does not fallback on it when an exception is thrown in this case.
Obviously the quick fix for you is to change the image to a png or jpg and see if it works.
Yes other image types seem to work.
I will remove the usage of System.Drawing.Common in for .NET framework in the GenericImageHandler , so it will use the build-in instead (Note that .NET core, .NET 6 & 7 already uses it). This should solve this issue.
I use EPPlus in a web application running in Azure. Version of .NET Framework is 4.8.4526.0.
Accessing worksheets containing drawings of type picture makes the application to chrash.
Crashdump from Azure:
InlinedCallFrame InlinedCallFrame DomainNeutralILStubClass.IL_STUB_PInvoke System.Drawing.Image.FromStream OfficeOpenXml.Drawing.GenericImageHandler.GetImageBounds OfficeOpenXml.ExcelImageSettings.GetImageBounds OfficeOpenXml.Drawing.PictureStore.GetImageBounds OfficeOpenXml.Drawing.PictureStore.AddImage OfficeOpenXml.Drawing.PictureStore.SavePicture OfficeOpenXml.Drawing.ExcelImage.SetImageContainer OfficeOpenXml.Drawing.ExcelPicture..ctor OfficeOpenXml.Drawing.ExcelDrawing.GetDrawingFromNode OfficeOpenXml.Drawing.ExcelDrawings.AddDrawings OfficeOpenXml.Drawing.ExcelDrawings..ctor OfficeOpenXml.ExcelWorksheets.Delete