EPPlusSoftware / EPPlus

EPPlus-Excel spreadsheets for .NET
https://epplussoftware.com
Other
1.82k stars 277 forks source link

Error "Worksheet position out of range" when calculating a worksheet #1671

Open hubaksis opened 1 week ago

hubaksis commented 1 week ago

EPPlus usage

Currently reviewing EPPlus before upgrading our project to the latest EPPlus version and purchasing a commercial license.

Environment

Windows

Epplus version

7.4.2

Spreadsheet application

Excel

Description

The following code throws an exception when attempting to process the attached file:

var filePath = @"[path-to]\Template-v68.xlsx";
using (var package = new ExcelPackage(new FileInfo(filePath)))
{
    var workbook = package.Workbook;
    var worksheet = workbook.Worksheets.FirstOrDefault();
    if (worksheet != null)
    {
        worksheet.Calculate();
    }
}

I’ve reduced the original file to the bare minimum after 3 hours of adjustments, hence version 68 :)

The exception occurs specifically when the following formulas are present on Sheet1:

B2 =VLOOKUP($A2,Sheet2!$A:$B,2,FALSE) C2 =VLOOKUP($A2,Sheet2!$A:$C,3,FALSE)

If I remove either of these formulas, the calculation completes without issues.

Template-v68.xlsx

swmal commented 1 week ago

Thanks, we will have a look at this.

swmal commented 1 week ago

@hubaksis Again thanks for the 3 hours spent on isolating this issue! It is now fixed and will be included in the next version of EPPlus. You can test it via our development nuget feed once PR #1672 has been closed.

hubaksis commented 6 days ago

Thank you for looking into this. I used the development feed, and the issue is resolved. We will wait for the main release before proceeding with a further upgrade.

Please feel free to close this bug according to your policy. I’m unsure if it should be closed now or after the official release.

swmal commented 5 days ago

@hubaksis thanks, we will close the issue when the fix has been released.