This is a migrated thread and some comments may be shown as answers.

Error when exporting report to XLSX: a generic error occurred in GDI+

4 Answers 1366 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Erik
Top achievements
Rank 1
Veteran
Erik asked on 02 Jul 2020, 03:06 PM

(Test carried out using the BarcodeTypes demo report)

On my development machine, all export formats work fine.

When deployed to Azure, some formats work, some don't:

_ PDF, CSV, XLS, Tiff & MHTML all work fine

_ XLSX, PowerPoint, RTF and Word all give the same GDI+ error

I have found other instances of GDI+ errors on the forum (related to PictureBox, PDF export, ...) but this seems to be a different type of exception

 

I am aware of Report Export issues on Azure with cheap plans, and have upgraded to a higher plan (Basic); PDF export didn't work on cheaper plan and that works now, so I assume this is an unrelated issue.

Error message:

w3wp.exe Error: 0 : An error occurred while rendering the report in separate thread: System.Runtime.InteropServices.ExternalException (0x80004005): A generic error occurred in GDI+.
   at System.Drawing.Imaging.Metafile..ctor(IntPtr referenceHdc, Rectangle frameRect, MetafileFrameUnit frameUnit, EmfType type, String desc)
   at System.Drawing.Imaging.Metafile..ctor(IntPtr referenceHdc, Rectangle frameRect, MetafileFrameUnit frameUnit, EmfType type)
   at Telerik.Reporting.Processing.Imaging.ImageUtils.CreateMetafileCore(Size sizePx) in c:\temp\reporting\RBuild-23266\Reporting_Build\Source\Code\Telerik.Reporting\Processing\Imaging\ImageUtils.Full.cs:line 105
   at Telerik.Reporting.Processing.Imaging.ImageUtils.CreateMetafileImage(SizeF sizeMm) in c:\temp\reporting\RBuild-23266\Reporting_Build\Source\Code\Telerik.Reporting\Processing\Imaging\ImageUtils.Full.cs:line 91
   at Telerik.Reporting.Processing.Imaging.MetafileImageFactory.CreateImage(SizeF sizeMm) in c:\temp\reporting\RBuild-23266\Reporting_Build\Source\Code\Telerik.Reporting\Processing\Imaging\ImageFactory.cs:line 26
   at Telerik.Reporting.ExcelRendering.Barcode.RenderInternal(IWorksheet worksheet, RenderingContext context) in c:\temp\reporting\RBuild-23266\Reporting_Build\Source\Code\Telerik.Reporting\ExcelRendering\Barcode.cs:line 21
   at Telerik.Reporting.ExcelRendering.RenderingItem.Render(IWorksheet worksheet, RenderingContext context) in c:\temp\reporting\RBuild-23266\Reporting_Build\Source\Code\Telerik.Reporting\ExcelRendering\RenderingItem.cs:line 364
   at Telerik.Reporting.ExcelRendering.RenderingItemContainer.RenderInternal(IWorksheet worksheet, RenderingContext context) in c:\temp\reporting\RBuild-23266\Reporting_Build\Source\Code\Telerik.Reporting\ExcelRendering\RenderingItemContainer.cs:line 108
   at Telerik.Reporting.ExcelRendering.Table.RenderInternal(IWorksheet worksheet, RenderingContext context) in c:\temp\reporting\RBuild-23266\Reporting_Build\Source\Code\Telerik.Reporting\ExcelRendering\Table.cs:line 31
   at Telerik.Reporting.ExcelRendering.RenderingItem.Render(IWorksheet worksheet, RenderingContext context) in c:\temp\reporting\RBuild-23266\Reporting_Build\Source\Code\Telerik.Reporting\ExcelRendering\RenderingItem.cs:line 364
   at Telerik.Reporting.ExcelRendering.RenderingItemContainer.RenderInternal(IWorksheet worksheet, RenderingContext context) in c:\temp\reporting\RBuild-23266\Reporting_Build\Source\Code\Telerik.Reporting\ExcelRendering\RenderingItemContainer.cs:line 108
   at Telerik.Reporting.ExcelRendering.Section.RenderInternal(IWorksheet worksheet, RenderingContext context) in c:\temp\reporting\RBuild-23266\Reporting_Build\Source\Code\Telerik.Reporting\ExcelRendering\Section.cs:line 26
   at Telerik.Reporting.ExcelRendering.RenderingItem.Render(IWorksheet worksheet, RenderingContext context) in c:\temp\reporting\RBuild-23266\Reporting_Build\Source\Code\Telerik.Reporting\ExcelRendering\RenderingItem.cs:line 364
   at Telerik.Reporting.ExcelRendering.Group.RenderInternal(IWorksheet worksheet, RenderingContext context) in c:\temp\reporting\RBuild-23266\Reporting_Build\Source\Code\Telerik.Reporting\ExcelRendering\Group.cs:line 47
   at Telerik.Reporting.ExcelRendering.RenderingItem.Render(IWorksheet worksheet, RenderingContext context) in c:\temp\reporting\RBuild-23266\Reporting_Build\Source\Code\Telerik.Reporting\ExcelRendering\RenderingItem.cs:line 364
   at Telerik.Reporting.ExcelRendering.RenderingItemContainer.RenderInternal(IWorksheet worksheet, RenderingContext context) in c:\temp\reporting\RBuild-23266\Reporting_Build\Source\Code\Telerik.Reporting\ExcelRendering\RenderingItemContainer.cs:line 108
   at Telerik.Reporting.ExcelRendering.Report.RenderInternal(IWorksheet worksheet, RenderingContext context) in c:\temp\reporting\RBuild-23266\Reporting_Build\Source\Code\Telerik.Reporting\ExcelRendering\Report.cs:line 202
   at Telerik.Reporting.ExcelRendering.RenderingItem.Render(IWorksheet worksheet, RenderingContext context) in c:\temp\reporting\RBuild-23266\Reporting_Build\Source\Code\Telerik.Reporting\ExcelRendering\RenderingItem.cs:line 364
   at Telerik.Reporting.ExcelRendering.Report.Render(IWorkbook workbook) in c:\temp\reporting\RBuild-23266\Reporting_Build\Source\Code\Telerik.Reporting\ExcelRendering\Report.cs:line 137
   at Telerik.Reporting.OpenXmlRendering.Spreadsheet.SpreadsheetReport.Telerik.Reporting.Processing.IRenderingExtension.Render(Report report, Hashtable renderingContext, Hashtable deviceInfo, CreateStream createStreamCallback, EvaluateHeaderFooterExpressions evalHeaderFooterCallback) in c:\temp\reporting\RBuild-23266\Reporting_Build\Source\Code\Telerik.Reporting.OpenXmlRendering\Spreadsheet\SpreadsheetReport.cs:line 40
   at Telerik.Reporting.Processing.ReportProcessor.RenderCore(ExtensionInfo extensionInfo, IList`1 processingReports, Hashtable deviceInfo, IRenderingContext renderingContext, CreateStream createStreamCallback) in c:\temp\reporting\RBuild-23266\Reporting_Build\Source\Code\Telerik.Reporting\Processing.ReportProcessor\ReportProcessor.RenderReport.cs:line 236
   at Telerik.Reporting.Processing.ReportProcessor.RenderCore(String format, IList`1 reports, Hashtable deviceInfo, IRenderingContext renderingContext, CreateStream createStreamCallback) in c:\temp\reporting\RBuild-23266\Reporting_Build\Source\Code\Telerik.Reporting\Processing.ReportProcessor\ReportProcessor.RenderReport.cs:line 157
   at Telerik.Reporting.Services.Engine.ReportRenderer.Render(ReportRendererArgs args) in c:\temp\reporting\RBuild-23266\Reporting_Build\Source\Code\Telerik.Reporting\Services.Engine\ReportRenderer.cs:line 40
   at Telerik.Reporting.Services.Engine.Rendering.RenderWithCulture(ReportRendererArgs args) in c:\temp\reporting\RBuild-23266\Reporting_Build\Source\Code\Telerik.Reporting\Services.Engine\Rendering.cs:line 152
   at Telerik.Reporting.Services.Engine.Rendering.ThreadFunc(Object o) in c:\temp\reporting\RBuild-23266\Reporting_Build\Source\Code\Telerik.Reporting\Services.Engine\Rendering.cs:line 120

 

 

Any hep would be greatly appreciated,

 

Erik

4 Answers, 1 is accepted

Sort by
0
Zach
Top achievements
Rank 1
answered on 17 Feb 2021, 11:44 AM

Greetings from Germany,

Erik, did you find the solution? I worked with the EPPlus .xlsx files (running in Azure). And the process produced “A generic error occurred in GDI+”

Zach Swedberg

 

docs.telerik.com/import-and-export-to-excel-file-formats/xlsx/xlsxformatprovider writemyessaysonline.com

0
Neli
Telerik team
answered on 19 Feb 2021, 08:07 AM

Hi Zach,

I noticed that the provided link was from the Document processing documentation. Can you please confirm that the problem is related to Telerik Reporting and the issue is reproducible when you try to run the hosted reports on Azure?

The Exception "A generic error occurred in GDI+" is thrown by the Graphics Device Interface (GDI) that we use internally to measure and render the items in our reports. It is a very general error and informs that the GDI processor cannot resolve an item - image, character, icon, etc.

Because the application is hosted in Azure, please, check GDI+ error or OutOfMemoryException on exporting or printing Telerik report from Azure WebSites KB article.

Regards,
Neli
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

1
Richard
Top achievements
Rank 1
answered on 26 Feb 2021, 09:42 AM

I had the same issue and adding this to app.settings fixed it:

 

  "telerikReporting": {
    "extensions": [
      {
        "name": "DOCX",
        "parameters": [
          {
            "Name": "UseMetafile",
            "Value": "false"
          }
        ]
      },
      {
        "name": "XLSX",
        "parameters": [
          {
            "Name": "UseMetafile",
            "Value": "false"
          }
        ]
      },
      {
        "name": "PPTX",
        "parameters": [
          {
            "Name": "UseMetafile",
            "Value": "false"
          }
        ]
      },
      {
        "name": "RTF",
        "parameters": [
          {
            "Name": "UseMetafile",
            "Value": "false"
          }
        ]
      }

    ]
  },

0
Jordan
Top achievements
Rank 1
Iron
answered on 21 Nov 2021, 06:35 PM
Thanks, for sharing this guide for solving the issue.
Tags
General Discussions
Asked by
Erik
Top achievements
Rank 1
Veteran
Answers by
Zach
Top achievements
Rank 1
Neli
Telerik team
Richard
Top achievements
Rank 1
Jordan
Top achievements
Rank 1
Iron
Share this question
or