Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ClosedXML - Could not load file or assembly

Tags:

.net

closedxml

I am trying to use ClosedXML to produce excel documents within an application however when ever I try to run it I receive a could not load file or assembly server error.

Could not load file or assembly 'DocumentFormat.OpenXml, Version=2.5.5631.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

I have seen several solution to this that include changing the 'Copy Local' value for the .dll in its properties and adding the assembly directly to the web.config.

I'm using Visual Studios 2010 and the dll properties does not include a 'copy local' entry. Then when I enter the following assembly in the web config I still get the same server error message. I got the assembly from the error message provided.

 <add assembly="ClosedXML, Version=0.76.0.0, Culture=neutral, PublicKeyToken=fd1eb21b62ae805b"/>
like image 868
Ethel Patrick Avatar asked Jan 20 '16 18:01

Ethel Patrick


People also ask

Can ClosedXML read XLS file?

ClosedXML is a . NET library for reading, manipulating and writing Excel 2007+ (. xlsx, . xlsm) files.

Does ClosedXML need Excel installed?

What can you do with this? ClosedXML allows you to create Excel files without the Excel application.

What is the difference between Openxml and ClosedXML?

ClosedXML is an open source library created based on OpenXmlSdk. It's more user friendly. ClosedXML is a . NET library for reading, manipulating and writing Excel 2007+ (.


1 Answers

After going crazy searching for answers and finally posting a question, I came across the simplest answer and once I referenced the additional .dll everything worked correctly.

To use ClosedXML you must reference the DocumentFormat.OpenXml.dll:

DocumentFormat.OpenXml.dll for NET 4.0+

like image 159
Ethel Patrick Avatar answered Oct 05 '22 11:10

Ethel Patrick