Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SUMIF attempts to access sum_range argument when it doesn't exist #563

Closed
colbybhearn opened this issue Dec 20, 2021 · 1 comment
Closed
Assignees
Labels
bug Something isn't working

Comments

@colbybhearn
Copy link
Contributor

If SUMIF is called where

  • range is a single cell, not a range.
  • criteria is anything that the single cell will pass
  • sum_range is not specified

then EPPlus throws System.ArgumentOutOfRangeException

Here's a test method that could be added to SumIfTests.cs

        [TestMethod]
        public void SumIfSingleCell()
        {
            _worksheet.Cells["A1"].Value = 20;
            _worksheet.Cells["A2"].Formula = "SUMIF(A1,\">0\")";
            _worksheet.Calculate();

            Assert.AreEqual(20d, _worksheet.Cells["A2"].Value);
        }

I'll try to whip up a PR with the simple fix I've made to SumIf.cs

@swmal swmal added the bug Something isn't working label Dec 28, 2021
@swmal
Copy link
Contributor

swmal commented Dec 28, 2021

Hi Colby,

I have added your unit test and your fix to SUMIF to the codebase. Will be included in the next version. Many thanks for your contribution.

/Mats

swmal added a commit that referenced this issue Dec 28, 2021
…570 - Invalid handling of numeric strings in COUNTIF, COUNTIFS and AVERAGEIFS
@swmal swmal closed this as completed Jan 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants