Open roland-jungwirth opened 11 months ago
Ugh! There are many descriptions of COUNTIF on the web, including Microsoft's own, and none of them describe this behavior. Further, while they all have lists of gotchas, none of them mention this. Excel evaluates =IF("something" > 0, TRUE, FALSE)
as TRUE
, yet doesn't count it for COUNTIF. Complicating any fix, the PhpSpreadsheet code for evaluating COUNTIF is shared by several other Excel functions, and I don't know that this particular wrinkle applies to all of them. So a fix may take a while.
It doesn't even point this out on Microsoft's own page: https://support.microsoft.com/en-us/office/countif-function-e0de10c6-f885-4e71-abb4-1f464816df34
This is:
What is the expected behavior?
When using
COUNTIF
in a cell (with a numerical condition), I expect the result to be the same when I reference the cell and use thegetCalculatedValue()
function.What is the current behavior?
The range B1:B8 has 6 numbers, on cell with text and one empty cell:
=COUNTIF(B1:B8;">0")
in Excel (cell "D2") returns 6 $spreadsheet->getActiveSheet()->getCell('D2')->getCalculatedValue() returns 7, as it includes the text cell.What are the steps to reproduce?
Here is the example Excel file I use countif.xlsx
What features do you think are causing the issue
Does an issue affect all spreadsheet file formats? If not, which formats are affected?
Which versions of PhpSpreadsheet and PHP are affected?
Probably all, but I am using PHP 8.1 and PhpSpreadsheet 1.29.