安装Open XML 2.0

use*_*764 4 c# xml openxml-sdk nuget-package spreadsheetlight

我正在尝试使用spreadsheetlight写入excel文件,但显然spreadsheetlight使用的是XML 2.0,我安装了2.5.我已经取消了2.5版本并且已经为我的项目添加了2.0参考,但我仍然收到一条错误消息,告诉我我正在使用2.5版本.我的问题很简单:如何让编译器(?)使用2.0版本而不是2.5版本?

真诚的阿克塞尔

Chr*_*sic 5

所以问题似乎是Spreadsheetlight nuget包在Nuspec中缺少必需的依赖项规范.

Install-Package DocumentFormat.OpenXml -Version 1.0.0


如果您已经安装了DocumentFormat.OpenXml并且正在获得类似的异常 Could not load type ‘DocumentFormat.OpenXml.Spreadsheet.SmartTags’ from assembly ‘DocumentFormat.OpenXml, Version=2.5.5631.0

UNinstall-Package DocumentFormat.OpenXml

如果您有程序集绑定重定向,请检查配置文件

  <dependentAssembly>
    <assemblyIdentity name="DocumentFormat.OpenXml" publicKeyToken="31bf3856ad364e35"... />
    <bindingRedirect oldVersion="0.0.0.0-2.5.5631.0" newVersion="2.5.5631.0" />
  </dependentAssembly>
Run Code Online (Sandbox Code Playgroud)

删除它.

现在安装特定版本:

Install-Package DocumentFormat.OpenXml -Version 1.0.0

来源:EricTummers.com获取Spreadsheetlight工作