PhpSpreadsheet icon indicating copy to clipboard operation
PhpSpreadsheet copied to clipboard

Incorrect SUMPRODUCT Calculation

Open oleibman opened this issue 1 year ago • 0 comments

Fix #3909. SUMPRODUCT is mishandling multi-row ranges. In Calculation/Calculation, checkMatrixOperands will often resize its operands. When it does so, it needs to recalculate the dimensions of each. This fixes the reported problem.

Likely cause was PR #3260. That ticket noted the poor coverage of the code being replaced. Tests of the problem in this ticket were absent and are now added. Despite this, I note that resizeMatricesShrink is virtually uncovered, and resizeMatricesExpand has substantial gaps in its coverage. I have covered some, but not all, of the Expand gaps. I am struggling to come up with examples to fill its remaining gaps and those for Shrink. However, I will merge this fix in about a week even if I don't succeed.

This is:

  • [x] a bugfix
  • [ ] a new feature
  • [ ] refactoring
  • [ ] additional unit tests

Checklist:

  • [x] Changes are covered by unit tests
    • [ ] Changes are covered by existing unit tests
    • [x] New unit tests have been added
  • [x] Code style is respected
  • [x] Commit message explains why the change is made (see https://github.com/erlang/otp/wiki/Writing-good-commit-messages)
  • [ ] CHANGELOG.md contains a short summary of the change and a link to the pull request if applicable
  • [ ] Documentation is updated as necessary

Why this change is needed?

Provide an explanation of why this change is needed, with links to any Issues (if appropriate). If this is a bugfix or a new feature, and there are no existing Issues, then please also create an issue that will make it easier to track progress with this PR.

oleibman avatar Feb 22 '24 07:02 oleibman