Fix Exception cases to always use the PhpSpreadsheet Calculation Exception
This commit is contained in:
parent
71bc7e6f89
commit
fb251eb6ab
|
|
@ -2329,7 +2329,7 @@ class Calculation
|
|||
],
|
||||
'SUMPRODUCT' => [
|
||||
'category' => Category::CATEGORY_MATH_AND_TRIG,
|
||||
'functionCall' => [MathTrig\SumProduct::class, 'evaluate'],
|
||||
'functionCall' => [MathTrig\Sum::class, 'product'],
|
||||
'argumentCount' => '1+',
|
||||
],
|
||||
'SUMSQ' => [
|
||||
|
|
|
|||
|
|
@ -840,8 +840,8 @@ class MathTrig
|
|||
*
|
||||
* @Deprecated 1.18.0
|
||||
*
|
||||
* @See MathTrig\SumProduct::evaluate()
|
||||
* Use the evaluate method in the MathTrig\SumProduct class instead
|
||||
* @See MathTrig\Sum::product()
|
||||
* Use the product method in the MathTrig\Sum class instead
|
||||
*
|
||||
* @param mixed ...$args Data values
|
||||
*
|
||||
|
|
@ -849,7 +849,7 @@ class MathTrig
|
|||
*/
|
||||
public static function SUMPRODUCT(...$args)
|
||||
{
|
||||
return MathTrig\SumProduct::evaluate(...$args);
|
||||
return MathTrig\Sum::product(...$args);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
|
||||
|
||||
use Exception;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Exception;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
|
||||
|
||||
class Arabic
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
|
||||
|
||||
use Exception;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Exception;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
|
||||
|
||||
class Base
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
|
||||
|
||||
use Exception;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Exception;
|
||||
|
||||
class Degrees
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
|
||||
|
||||
use Exception;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Exception;
|
||||
|
||||
class Exp
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
|
||||
|
||||
use Exception;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Exception;
|
||||
|
||||
class IntClass
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
|
||||
|
||||
use Exception;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Exception;
|
||||
|
||||
class Mod
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
|
||||
|
||||
use Exception;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Exception;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
|
||||
|
||||
class Power
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
|
||||
|
||||
use Exception;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Exception;
|
||||
|
||||
class Quotient
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
|
||||
|
||||
use Exception;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Exception;
|
||||
|
||||
class Radians
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
|
||||
|
||||
use Exception;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Exception;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
|
||||
|
||||
class Roman
|
||||
|
|
@ -769,6 +769,7 @@ class Roman
|
|||
3998 => ['MMMLMVLIII', 'MMMXMVIII', 'MMMVMIII'],
|
||||
3999 => ['MMMLMVLIV', 'MMMXMIX', 'MMMVMIV', 'MMMIM'],
|
||||
];
|
||||
|
||||
private const THOUSANDS = ['', 'M', 'MM', 'MMM'];
|
||||
private const HUNDREDS = ['', 'C', 'CC', 'CCC', 'CD', 'D', 'DC', 'DCC', 'DCCC', 'CM'];
|
||||
private const TENS = ['', 'X', 'XX', 'XXX', 'XL', 'L', 'LX', 'LXX', 'LXXX', 'XC'];
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
|
||||
|
||||
use Exception;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Exception;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
|
||||
|
||||
class SeriesSum
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
|
||||
|
||||
use Exception;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Exception;
|
||||
|
||||
class Sign
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
|
||||
|
||||
use Exception;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Exception;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Statistical;
|
||||
|
||||
|
|
@ -52,7 +52,7 @@ class Subtotal
|
|||
|
||||
/** @var callable[] */
|
||||
private const CALL_FUNCTIONS = [
|
||||
1 => [Statistical\Averages::class, 'AVERAGE'],
|
||||
1 => [Statistical\Averages::class, 'average'],
|
||||
[Statistical\Counts::class, 'COUNT'], // 2
|
||||
[Statistical\Counts::class, 'COUNTA'], // 3
|
||||
[Statistical\Maximum::class, 'MAX'], // 4
|
||||
|
|
|
|||
|
|
@ -71,4 +71,45 @@ class Sum
|
|||
|
||||
return $returnValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* SUMPRODUCT.
|
||||
*
|
||||
* Excel Function:
|
||||
* SUMPRODUCT(value1[,value2[, ...]])
|
||||
*
|
||||
* @param mixed ...$args Data values
|
||||
*
|
||||
* @return float|string The result, or a string containing an error
|
||||
*/
|
||||
public static function product(...$args)
|
||||
{
|
||||
$arrayList = $args;
|
||||
|
||||
$wrkArray = Functions::flattenArray(array_shift($arrayList));
|
||||
$wrkCellCount = count($wrkArray);
|
||||
|
||||
for ($i = 0; $i < $wrkCellCount; ++$i) {
|
||||
if ((!is_numeric($wrkArray[$i])) || (is_string($wrkArray[$i]))) {
|
||||
$wrkArray[$i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($arrayList as $matrixData) {
|
||||
$array2 = Functions::flattenArray($matrixData);
|
||||
$count = count($array2);
|
||||
if ($wrkCellCount != $count) {
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
foreach ($array2 as $i => $val) {
|
||||
if ((!is_numeric($val)) || (is_string($val))) {
|
||||
$val = 0;
|
||||
}
|
||||
$wrkArray[$i] *= $val;
|
||||
}
|
||||
}
|
||||
|
||||
return array_sum($wrkArray);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,49 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
|
||||
|
||||
class SumProduct
|
||||
{
|
||||
/**
|
||||
* SUMPRODUCT.
|
||||
*
|
||||
* Excel Function:
|
||||
* SUMPRODUCT(value1[,value2[, ...]])
|
||||
*
|
||||
* @param mixed ...$args Data values
|
||||
*
|
||||
* @return float|string The result, or a string containing an error
|
||||
*/
|
||||
public static function evaluate(...$args)
|
||||
{
|
||||
$arrayList = $args;
|
||||
|
||||
$wrkArray = Functions::flattenArray(array_shift($arrayList));
|
||||
$wrkCellCount = count($wrkArray);
|
||||
|
||||
for ($i = 0; $i < $wrkCellCount; ++$i) {
|
||||
if ((!is_numeric($wrkArray[$i])) || (is_string($wrkArray[$i]))) {
|
||||
$wrkArray[$i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($arrayList as $matrixData) {
|
||||
$array2 = Functions::flattenArray($matrixData);
|
||||
$count = count($array2);
|
||||
if ($wrkCellCount != $count) {
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
foreach ($array2 as $i => $val) {
|
||||
if ((!is_numeric($val)) || (is_string($val))) {
|
||||
$val = 0;
|
||||
}
|
||||
$wrkArray[$i] *= $val;
|
||||
}
|
||||
}
|
||||
|
||||
return array_sum($wrkArray);
|
||||
}
|
||||
}
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
|
||||
|
||||
use Exception;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Exception;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
|
||||
|
||||
class SumSquares
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
|
||||
|
||||
use Exception;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Exception;
|
||||
|
||||
class Trunc
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue