JanKallman / EPPlus

Create advanced Excel spreadsheets using .NET
3.75k stars 1.18k forks source link

StackOverflowException when calling Clear on a comma separated Range #560

Open burtonrodman opened 4 years ago

burtonrodman commented 4 years ago

When calling Clear on a range that was specified as comma separated like below, a StackOverflowException occurs.

my csproj file:

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

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp3.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="EPPlus" Version="4.5.3.2" />
  </ItemGroup>

</Project>

the code file: `using System; using System.IO; using OfficeOpenXml;

namespace epplus_stackoverflowexception { class Program { static void Main(string[] args) { var pkgfi = new FileInfo("test.xlsx");

        using (var pkg = new ExcelPackage())
        {
            var ws = pkg.Workbook.Worksheets.Add("Sheet1");
            ws.Cells["A1:B2, C3:D4"].Value = 5;
            pkg.SaveAs(pkgfi);
        }

        using (var pkg = new ExcelPackage(pkgfi))
        {
            var ws = pkg.Workbook.Worksheets["Sheet1"];
            ws.Cells["A1:B2, C3:D4"].Clear();
            pkg.Save();
        }

        Console.WriteLine("done");
    }
}

}`

burtonrodman commented 4 years ago

for reference, this also occurs in a full framework Windows Forms project targeting 4.6.1