Skip to content

xlstream-eval: wildcard criteria match text cells only#185

Merged
cilladev merged 2 commits into
mainfrom
fix/sumif-wildcard-text
Jun 3, 2026
Merged

xlstream-eval: wildcard criteria match text cells only#185
cilladev merged 2 commits into
mainfrom
fix/sumif-wildcard-text

Conversation

@cilladev

@cilladev cilladev commented Jun 3, 2026

Copy link
Copy Markdown
Owner

Fixes: #142

Problem

=SUMIF(range, "*", sum_range) matched every cell type, including numbers. The wildcard arm of Criteria::matches coerced each value to text before matching, so "*" (and any wildcard) matched numbers. Excel only matches text cells with wildcards.

Fix

The Criteria::Wildcard arm now matches Value::Text only. Numbers, booleans, dates, errors, and blanks never match a wildcard, regardless of their text rendering — matching Excel.

Changes

  • crates/xlstream-eval/src/criteria.rs: wildcard arm matches Value::Text only; drop now-unused coerce import.
  • Two unit tests (wildcard_skips_non_text, wildcard_does_not_match_numeric_pattern) — both fail pre-fix, pass post-fix.
  • Conformance fixture issue-142-sumif-wildcard-text-only.xlsx (Excel-populated cached values) covering "*", "y*", "?es", plus controls ("<>" NonBlank and ">100") proving non-wildcard criteria still include numbers.

Scope note — separate pre-existing bug (not fixed here)

While verifying, I found COUNTIF/COUNTIFS and AVERAGEIF with wildcard/operator criteria return wrong values: try_operator_criteria re-folds already-finished per-bucket aggregates, which is correct for SUM/MIN/MAX/PRODUCT but counts buckets (not rows) for COUNT and averages-of-averages for AVERAGE. This is independent of wildcards and of this fix, and is already tracked in #174. A correct fix is architectural (store deferred FoldStates instead of finished Values), so it is intentionally out of scope. The fixture is SUMIF-only to avoid entangling #174.

Test plan

  • Regression unit tests added and pass
  • Conformance fixture created (Excel-populated) and passes
  • cargo test -p xlstream-eval passes (2261 lib + 137 doc, no regressions)
  • make check passes

Closes #142

@cilladev cilladev force-pushed the fix/sumif-wildcard-text branch from ce24ff4 to 28944b3 Compare June 3, 2026 22:41
@cilladev cilladev merged commit c90c6b8 into main Jun 3, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SUMIF wildcard * matches numbers (should only match text)

1 participant