Apply filter check on cells that already contain a subtotal calculation... will add unit tests later
This commit is contained in:
parent
36acc37287
commit
df34b15079
|
@ -1081,6 +1081,21 @@ class MathTrig
|
|||
);
|
||||
}
|
||||
|
||||
protected static function filterFormulaArgs($cellReference, $args)
|
||||
{
|
||||
return array_filter(
|
||||
$args,
|
||||
function ($index) use ($cellReference) {
|
||||
list(, $row, $column) = explode('.', $index);
|
||||
|
||||
//take this cell out if it contains the SUBTOTAL formula
|
||||
return strpos(strtoupper($cellReference->getWorksheet()->getCell($column . $row)->getValue()), '=SUBTOTAL(') === false;
|
||||
|
||||
},
|
||||
ARRAY_FILTER_USE_KEY
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* SUBTOTAL.
|
||||
*
|
||||
|
@ -1105,6 +1120,7 @@ class MathTrig
|
|||
$subtotal = $subtotal - 100;
|
||||
}
|
||||
|
||||
$aArgs = self::filterFormulaArgs($cellReference, $aArgs);
|
||||
switch ($subtotal) {
|
||||
case 1:
|
||||
return Statistical::AVERAGE($aArgs);
|
||||
|
|
Loading…
Reference in New Issue