Could not load file or assembly 'DocumentFormat.OpenXml

I had this problem because I had a new version of the .dll installed on my computer running on localhost and my server was running an old version of the same .dll

I just updated it and everything works well after that.

In your case, install the DocumentFormat.OpenXml version 2.5 available in this microsoft link


At the time of writing this answer, there are 3 versions of Open XML SDK:

  • Open XML SDK 1.0 (NuGet link)
  • Open XML SDK 2.0 (NuGet link)
  • Open XML SDK 2.5 (NuGet link)

You most probably have referenced in your project DLL version 2.5 which was installed on your machine.
To get required v2.0 assembly, I suggest you to use NuGet I provided above.