Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

303
Views
Why Does EPPlus Excel Library in AWS Lambda Environment Throw "The type initializer for 'Gdip' threw an exception"

Posting this question for others experiencing the same issue. My answer below.

I created an AWS Lambda method that receives a series of query parameters that are used to produce a report. The report data is saved in an Excel file using the excellent EPPlus library. When I run the code in the development environment it executes without a problem. After I deploy the code to AWS and call it via the URL I get the following exception:

The type initializer for 'Gdip' threw an exception

Why would this happen after deployment, yet run properly in the development environment?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

What I was able to determine is that the error occurs when attempting to automatically size column widths to fit the supplied data in one of the worksheets. EPPlus helpfully supplies an AutoFitColumns method for a range that will size the columns based on the widest data in the range. Once I pinpointed this line of code as the source of the exception it all made sense.

I have not confirmed this, but I assume that EPPlus loops through the text in each cell of the range and calls the .Net Graphics.MeasureString method from the System.Drawing namespace to determine the width of the rendered text. Once the widest string is determined the column width is set accordingly.

The problem is that it appears that the GDI+ API is not available in the AWS lambda environment. I believe you can add libgdiplus to your AWS Lambda environment (see forum discussions here and here). However, I did not attempt to change my configuration, instead opting for default column widths with word wrap enabled.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!