Why do I get System.InvalidProgramException when I use Spreadsheet Light v3.5.0 with DocumentFormat.OpenXml v3.0.0?

112 Views Asked by At

When I try to use the latest version of DocumentFormat.OpenXml with Spreadsheet Light I get the following exception.

Exception and call stack

I have trimmed my code down to this. The exception occurs when the SLDocument constructor is called.

using SpreadsheetLight;

var template = new SLDocument();

This is my project file.

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net7.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="DocumentFormat.OpenXml" Version="3.0.0" />
    <PackageReference Include="SpreadsheetLight" Version="3.5.0" />
  </ItemGroup>

</Project>

This works with DocumentFormat.OpenXml v2.20.0, but fails when it is upgraded.

1

There are 1 best solutions below

1
On

it is the DocumentFormat.OpenXml version. Spreadsheet Light works whit >=2.11.3 i have found the DocumentFormat.OpenXml version 2.20.0 works best