You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When calculating the value of a formula field that it would match what Excel shows.
What is the current behavior?
Using this spreadsheet as an example:
Using the following named rages:
calHours => =Sheet1!$B$3:$G$9
calNames => =Sheet1!$B$1:$G$1
calSums => =Sheet1!$B$10:$G$10
calTiers => =Sheet1!$B$2:$G$2
When calculating a SUMPRODUCT formula like =SUMPRODUCT(((calNames=I3)*(calTiers=$K$2))*calHours) where calHours is a multi-row range the value is incorrect. If the named range calHours is replaced with calSums which is a single-row range it will calculate correctly.
Version 1.28.0 and higher will return the following values:
If this is an issue with reading a specific spreadsheet file, then it may be appropriate to provide a sample file that demonstrates the problem; but please keep it as small as possible, and sanitize any confidential information before uploading.
Does an issue affect all spreadsheet file formats? If not, which formats are affected?
Haven't tested, but confirmed that xlsm and xslx are affected.
Which versions of PhpSpreadsheet and PHP are affected?
Version 1.26.0 is last version that would correctly calculate values for multi-row and single-row ranges.
Version 1.27.x regressed to calculating 0 as the value for both multi-row and single-row ranges.
Version 1.28.0 and higher calculate incorrect values for multi-row ranges
Tested with PHP 8.0.30, 8.1.27, 8.2.14, and 8.3.1 and all gave same results.
The text was updated successfully, but these errors were encountered:
oleibman
added a commit
to oleibman/PhpSpreadsheet
that referenced
this issue
Feb 22, 2024
FixPHPOffice#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 PHPOffice#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:
What is the expected behavior?
When calculating the value of a formula field that it would match what Excel shows.
What is the current behavior?
Using this spreadsheet as an example:
Using the following named rages:
calHours
=>=Sheet1!$B$3:$G$9
calNames
=>=Sheet1!$B$1:$G$1
calSums
=>=Sheet1!$B$10:$G$10
calTiers
=>=Sheet1!$B$2:$G$2
When calculating a SUMPRODUCT formula like
=SUMPRODUCT(((calNames=I3)*(calTiers=$K$2))*calHours)
wherecalHours
is a multi-row range the value is incorrect. If the named rangecalHours
is replaced withcalSums
which is a single-row range it will calculate correctly.Version 1.28.0 and higher will return the following values:
What are the steps to reproduce?
Please provide a Minimal, Complete, and Verifiable example of code that exhibits the issue without relying on an external Excel file or a web server:
If this is an issue with reading a specific spreadsheet file, then it may be appropriate to provide a sample file that demonstrates the problem; but please keep it as small as possible, and sanitize any confidential information before uploading.
minimum.xlsx
What features do you think are causing the issue
Does an issue affect all spreadsheet file formats? If not, which formats are affected?
Haven't tested, but confirmed that
xlsm
andxslx
are affected.Which versions of PhpSpreadsheet and PHP are affected?
Version 1.26.0 is last version that would correctly calculate values for multi-row and single-row ranges.
Version 1.27.x regressed to calculating 0 as the value for both multi-row and single-row ranges.
Version 1.28.0 and higher calculate incorrect values for multi-row ranges
Tested with PHP 8.0.30, 8.1.27, 8.2.14, and 8.3.1 and all gave same results.
The text was updated successfully, but these errors were encountered: