[SE] fixed bounded COUNTIF case with ' in range and empty searchValue

This commit is contained in:
Aleksandr Nagaev
2026-01-15 02:12:35 +03:00
parent 1159a26f7d
commit 434fc786e5
2 changed files with 13 additions and 10 deletions

View File

@ -12584,7 +12584,9 @@ function (window, undefined) {
const bbox = range.getBBox0();
const cellsCount = (bbox.c2 - bbox.c1 + 1) * (bbox.r2 - bbox.r1 + 1);
const elemsCount = this.typedCache.getElemsCount(range);
const emptyCount = cellsCount - elemsCount;
let emptyCount = cellsCount - elemsCount;
let matchingFunction = getMatchingFunction(cElementType.string, '=', false);
emptyCount += this.typedCache.forEachInTyped(range, cElementType.string, matchingFunction, searchValue);
return new cNumber(emptyCount);
}
if (matchingInfo.op === "<>") {

View File

@ -10162,22 +10162,23 @@ $(function () {
assert.ok(oParser.parse());
assert.strictEqual(oParser.calculate().getValue(), 3);
// Case #8: Area, String. Count empty values. ' as Empty. Different with Ms
// ws.getRange2("A321").setValue("");
// ws.getRange2("A322").setValue("");
// ws.getRange2("A323").setValue("'");
// oParser = new parserFormula('COUNTIF(A321:A323,"")', "C2", ws);
// assert.ok(oParser.parse());
// assert.strictEqual(oParser.calculate().getValue(), 3);
// Case #8: Area, String. Count empty values. ' as Empty.
ws.getRange2("A321").setValue("");
ws.getRange2("A322").setValue("");
ws.getRange2("A323").setValue("'");
oParser = new parserFormula('COUNTIF(A321:A323,"")', "C2", ws);
assert.ok(oParser.parse());
assert.strictEqual(oParser.calculate().getValue(), 3);
// Case #9: Area, String. Count specific numbers in range with strings and numbers
ws.getRange2("A324").setValue("123");
ws.getRange2("A325").setValue("123.0");
ws.getRange2("A326").setValue("0123");
ws.getRange2("A327").setValue("1.23E+02");
AscCommonExcel.g_oCountIfCache.clean();
oParser = new parserFormula('COUNTIF(A324:A326,"123.00")', "AC7", ws);
oParser = new parserFormula('COUNTIF(A324:A327,"123.00")', "AC7", ws);
assert.ok(oParser.parse());
assert.strictEqual(oParser.calculate().getValue(), 3);
assert.strictEqual(oParser.calculate().getValue(), 4);
// testArrayFormula2(assert, "COUNTIF", 2, 2)
});