4

I'm trying to use spreadsheetlight to write to excel file, but apparently spreadsheetlight uses XML 2.0 and I have 2.5 installed. I've unistalled the 2.5 version and have added the 2.0 reference to my project, but I still get an error message telling me that I'm using the 2.5 version. And my question is simply: how do I get the compiler (?) to use the 2.0 version rather than the 2.5 version?

Sincerely Axel

user2950764
  • 211
  • 4
  • 13
  • 1
    Did you try de-referencing the old sdk, cleaning the solution and rebuilding it after adding 2.0? – LakshmiNarayanan Apr 07 '14 at 11:48
  • I'm not sure how you mean I should de-reference? I've unmarked the System.XML in the "Assemblies" tab in "Add reference" so that only the new I've added is marked, but that didn't help. Cleaning the solution isn't something I've tried, can one do that without risking to loose data? – user2950764 Apr 07 '14 at 11:54
  • 1
    Sorry should have been clearer. I was referring to remove the namespace and rebuilding. However, I do not think adding System.XML would resolve your issue. If you can find `DocumentFormat.OpenXml` dll from the reference and add it to your solution, after installing the 2.0 sdk, I think the complier would not throw any errors. Refer [this](http://msdn.microsoft.com/en-us/library/bb497430(v=office.14).aspx) using namespace `DocumentFormat.OpenXml` – LakshmiNarayanan Apr 07 '14 at 12:09
  • Removing the namespace? Sorry but I don't follow at all. I'm already refer to that namespace "using DocumentFormat.OpenXml" since I used the 2.5 version (apparently, SpreadSheetLight can read but not write using 2.5). But do you mean that I should remove that (and all code depending on it), rebuild the project and then adding it again? – user2950764 Apr 07 '14 at 12:19
  • 1
    If you had already referred to DocumentFormat.Openxml, it is possible that your application still refers to the old sdk. Try rebuilding the solution after adding the new reference to DocumentFormat.OpenXml, which I suppose should solve the compilation error. – LakshmiNarayanan Apr 07 '14 at 12:43
  • Well, it's not a compilation error but an exception thrown when I try to save the excel file. But I should try to rebuild the application and see if that'll cut it! – user2950764 Apr 07 '14 at 15:34

2 Answers2

6

So the issue appears to be the Spreadsheetlight nuget package is missing a required dependency specification in the Nuspec.

Install-Package DocumentFormat.OpenXml -Version 1.0.0


If you have already installed DocumentFormat.OpenXml and are getting an exception similar to Could not load type ‘DocumentFormat.OpenXml.Spreadsheet.SmartTags’ from assembly ‘DocumentFormat.OpenXml, Version=2.5.5631.0

UNinstall-Package DocumentFormat.OpenXml

Check your config files, if you have an assembly binding redirect

  <dependentAssembly>
    <assemblyIdentity name="DocumentFormat.OpenXml" publicKeyToken="31bf3856ad364e35"... />
    <bindingRedirect oldVersion="0.0.0.0-2.5.5631.0" newVersion="2.5.5631.0" />
  </dependentAssembly>

Delete this.

Now install the specific version:

Install-Package DocumentFormat.OpenXml -Version 1.0.0

Source: EricTummers.com Get Spreadsheetlight working

Chris Marisic
  • 32,487
  • 24
  • 164
  • 258
2

Current SpreadsheetLight version 3.4 requires Open XML SDK v2.0 assembly.

Here you'll find the link to the NuGet package which contains required assembly.

Community
  • 1
  • 1
HRKoder
  • 1,646
  • 15
  • 11