ClosedXML - 无法加载文件或程序集

Eth*_*ick 7 .net closedxml

我试图使用ClosedXML在应用程序中生成excel文档,但是当我尝试运行它时,我收到一个无法加载文件或程序集服务器错误.

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.
Run Code Online (Sandbox Code Playgroud)

我已经看到了几个解决方案,包括在其属性中更改.dll的'Copy Local'值并将程序集直接添加到web.config.

我正在使用Visual Studios 2010,并且dll属性不包含"复制本地"条目.然后,当我在Web配置中输入以下程序集时,我仍然收到相同的服务器错误消息.我从提供的错误消息中获得了程序集.

 <add assembly="ClosedXML, Version=0.76.0.0, Culture=neutral, PublicKeyToken=fd1eb21b62ae805b"/>
Run Code Online (Sandbox Code Playgroud)

Eth*_*ick 5

在疯狂寻找答案并最终发布问题之后,我遇到了最简单的答案,一旦我引用了额外的.dll一切正常.

要使用ClosedXML,您必须引用DocumentFormat.OpenXml.dll:

适用于.NET 4.0+的DocumentFormat.OpenXml.dll