feat(calc): support matrix logic and products #2257
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR Details
Enable element-wise comparison and multiplication for matrix operands. Use broadcasting for scalar-matrix operations to ensure consistent behavior during complex formula evaluation.
Add range-to-range matching support for COUNTIF. This enables formulas like SUMPRODUCT with conditionals and improves parity with standard spreadsheet matrix logic.
Description
This PR adds element-wise array operation support to the calculation engine, enabling conditional array formulas and range-based calculations. This allows comparison and arithmetic operators to work with matrix data.
New Capabilities:
COUNTIF(D:D, D:D)can now check if each value exists anywhere in a criteria rangeSUMPRODUCT((A1:A6="Apple")*(B1:B6))enables filtering and aggregation based on conditions=,<>,<,<=,>,>=) and multiplication (*) now support array operations with scalar broadcastingComparison operators now return boolean arrays when operating on ranges, enabling conditional logic in formulas:
COUNTIF now accepts range references as criteria, checking if each search value matches any value in the criteria range:
SUMPRODUCT can now use comparison expressions to filter data before aggregation:
Related Issue
Motivation and Context
This change enables conditional array formulas and advanced range-based calculations that are essential for complex data analysis in spreadsheets.
What users couldn't do before:
What this unlocks:
This brings excelize's formula calculation capabilities in line with Excel's array formula support, enabling users to perform sophisticated data analysis directly in their spreadsheet formulas.
How Has This Been Tested
Various new tests
Types of changes
Checklist