More PSR-2 modifications
This commit is contained in:
parent
b8f67c6f4d
commit
c07b54172a
|
@ -1,6 +1,16 @@
|
|||
<?php
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* PHPExcel
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||
}
|
||||
|
||||
/**
|
||||
* PHPExcel_Calculation_DateTime
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
|
@ -24,25 +34,6 @@
|
|||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Calculation_DateTime
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Calculation
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Calculation_DateTime
|
||||
{
|
||||
/**
|
||||
|
@ -95,12 +86,12 @@ class PHPExcel_Calculation_DateTime
|
|||
|
||||
|
||||
/**
|
||||
* _getDateValue
|
||||
* getDateValue
|
||||
*
|
||||
* @param string $dateValue
|
||||
* @return mixed Excel date/time serial value, or string if error
|
||||
*/
|
||||
public static function _getDateValue($dateValue)
|
||||
public static function getDateValue($dateValue)
|
||||
{
|
||||
if (!is_numeric($dateValue)) {
|
||||
if ((is_string($dateValue)) &&
|
||||
|
@ -121,12 +112,12 @@ class PHPExcel_Calculation_DateTime
|
|||
|
||||
|
||||
/**
|
||||
* _getTimeValue
|
||||
* getTimeValue
|
||||
*
|
||||
* @param string $timeValue
|
||||
* @return mixed Excel date/time serial value, or string if error
|
||||
*/
|
||||
private static function _getTimeValue($timeValue)
|
||||
private static function getTimeValue($timeValue)
|
||||
{
|
||||
$saveReturnDateType = PHPExcel_Calculation_Functions::getReturnDateType();
|
||||
PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL);
|
||||
|
@ -136,7 +127,7 @@ class PHPExcel_Calculation_DateTime
|
|||
}
|
||||
|
||||
|
||||
private static function _adjustDateByMonths($dateValue = 0, $adjustmentMonths = 0)
|
||||
private static function adjustDateByMonths($dateValue = 0, $adjustmentMonths = 0)
|
||||
{
|
||||
// Execute function
|
||||
$PHPDateObject = PHPExcel_Shared_Date::ExcelToPHPObject($dateValue);
|
||||
|
@ -669,10 +660,10 @@ class PHPExcel_Calculation_DateTime
|
|||
$endDate = PHPExcel_Calculation_Functions::flattenSingleValue($endDate);
|
||||
$unit = strtoupper(PHPExcel_Calculation_Functions::flattenSingleValue($unit));
|
||||
|
||||
if (is_string($startDate = self::_getDateValue($startDate))) {
|
||||
if (is_string($startDate = self::getDateValue($startDate))) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
}
|
||||
if (is_string($endDate = self::_getDateValue($endDate))) {
|
||||
if (is_string($endDate = self::getDateValue($endDate))) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
}
|
||||
|
||||
|
@ -791,10 +782,10 @@ class PHPExcel_Calculation_DateTime
|
|||
$startDate = PHPExcel_Calculation_Functions::flattenSingleValue($startDate);
|
||||
$endDate = PHPExcel_Calculation_Functions::flattenSingleValue($endDate);
|
||||
|
||||
if (is_string($startDate = self::_getDateValue($startDate))) {
|
||||
if (is_string($startDate = self::getDateValue($startDate))) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
}
|
||||
if (is_string($endDate = self::_getDateValue($endDate))) {
|
||||
if (is_string($endDate = self::getDateValue($endDate))) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
}
|
||||
|
||||
|
@ -848,10 +839,10 @@ class PHPExcel_Calculation_DateTime
|
|||
$endDate = PHPExcel_Calculation_Functions::flattenSingleValue($endDate);
|
||||
$method = PHPExcel_Calculation_Functions::flattenSingleValue($method);
|
||||
|
||||
if (is_string($startDate = self::_getDateValue($startDate))) {
|
||||
if (is_string($startDate = self::getDateValue($startDate))) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
}
|
||||
if (is_string($endDate = self::_getDateValue($endDate))) {
|
||||
if (is_string($endDate = self::getDateValue($endDate))) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
}
|
||||
|
||||
|
@ -949,11 +940,11 @@ class PHPExcel_Calculation_DateTime
|
|||
array_shift($dateArgs);
|
||||
|
||||
// Validate the start and end dates
|
||||
if (is_string($startDate = $sDate = self::_getDateValue($startDate))) {
|
||||
if (is_string($startDate = $sDate = self::getDateValue($startDate))) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
}
|
||||
$startDate = (float) floor($startDate);
|
||||
if (is_string($endDate = $eDate = self::_getDateValue($endDate))) {
|
||||
if (is_string($endDate = $eDate = self::getDateValue($endDate))) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
}
|
||||
$endDate = (float) floor($endDate);
|
||||
|
@ -982,7 +973,7 @@ class PHPExcel_Calculation_DateTime
|
|||
// Test any extra holiday parameters
|
||||
$holidayCountedArray = array();
|
||||
foreach ($dateArgs as $holidayDate) {
|
||||
if (is_string($holidayDate = self::_getDateValue($holidayDate))) {
|
||||
if (is_string($holidayDate = self::getDateValue($holidayDate))) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
}
|
||||
if (($holidayDate >= $startDate) && ($holidayDate <= $endDate)) {
|
||||
|
@ -1035,7 +1026,7 @@ class PHPExcel_Calculation_DateTime
|
|||
array_shift($dateArgs);
|
||||
array_shift($dateArgs);
|
||||
|
||||
if ((is_string($startDate = self::_getDateValue($startDate))) || (!is_numeric($endDays))) {
|
||||
if ((is_string($startDate = self::getDateValue($startDate))) || (!is_numeric($endDays))) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
}
|
||||
$startDate = (float) floor($startDate);
|
||||
|
@ -1069,7 +1060,7 @@ class PHPExcel_Calculation_DateTime
|
|||
$holidayCountedArray = $holidayDates = array();
|
||||
foreach ($dateArgs as $holidayDate) {
|
||||
if (($holidayDate !== null) && (trim($holidayDate) > '')) {
|
||||
if (is_string($holidayDate = self::_getDateValue($holidayDate))) {
|
||||
if (is_string($holidayDate = self::getDateValue($holidayDate))) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
}
|
||||
if (self::DAYOFWEEK($holidayDate, 3) < 5) {
|
||||
|
@ -1136,7 +1127,7 @@ class PHPExcel_Calculation_DateTime
|
|||
|
||||
if ($dateValue === null) {
|
||||
$dateValue = 1;
|
||||
} elseif (is_string($dateValue = self::_getDateValue($dateValue))) {
|
||||
} elseif (is_string($dateValue = self::getDateValue($dateValue))) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
} elseif ($dateValue == 0.0) {
|
||||
return 0;
|
||||
|
@ -1182,7 +1173,7 @@ class PHPExcel_Calculation_DateTime
|
|||
|
||||
if ($dateValue === null) {
|
||||
$dateValue = 1;
|
||||
} elseif (is_string($dateValue = self::_getDateValue($dateValue))) {
|
||||
} elseif (is_string($dateValue = self::getDateValue($dateValue))) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
} elseif ($dateValue < 0.0) {
|
||||
return PHPExcel_Calculation_Functions::NaN();
|
||||
|
@ -1258,7 +1249,7 @@ class PHPExcel_Calculation_DateTime
|
|||
|
||||
if ($dateValue === null) {
|
||||
$dateValue = 1;
|
||||
} elseif (is_string($dateValue = self::_getDateValue($dateValue))) {
|
||||
} elseif (is_string($dateValue = self::getDateValue($dateValue))) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
} elseif ($dateValue < 0.0) {
|
||||
return PHPExcel_Calculation_Functions::NaN();
|
||||
|
@ -1297,7 +1288,7 @@ class PHPExcel_Calculation_DateTime
|
|||
|
||||
if ($dateValue === null) {
|
||||
$dateValue = 1;
|
||||
} elseif (is_string($dateValue = self::_getDateValue($dateValue))) {
|
||||
} elseif (is_string($dateValue = self::getDateValue($dateValue))) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
} elseif ($dateValue < 0.0) {
|
||||
return PHPExcel_Calculation_Functions::NaN();
|
||||
|
@ -1329,7 +1320,7 @@ class PHPExcel_Calculation_DateTime
|
|||
|
||||
if ($dateValue === null) {
|
||||
$dateValue = 1;
|
||||
} elseif (is_string($dateValue = self::_getDateValue($dateValue))) {
|
||||
} elseif (is_string($dateValue = self::getDateValue($dateValue))) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
} elseif ($dateValue < 0.0) {
|
||||
return PHPExcel_Calculation_Functions::NaN();
|
||||
|
@ -1366,7 +1357,7 @@ class PHPExcel_Calculation_DateTime
|
|||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
}
|
||||
}
|
||||
$timeValue = self::_getTimeValue($timeValue);
|
||||
$timeValue = self::getTimeValue($timeValue);
|
||||
if (is_string($timeValue)) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
}
|
||||
|
@ -1407,7 +1398,7 @@ class PHPExcel_Calculation_DateTime
|
|||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
}
|
||||
}
|
||||
$timeValue = self::_getTimeValue($timeValue);
|
||||
$timeValue = self::getTimeValue($timeValue);
|
||||
if (is_string($timeValue)) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
}
|
||||
|
@ -1448,7 +1439,7 @@ class PHPExcel_Calculation_DateTime
|
|||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
}
|
||||
}
|
||||
$timeValue = self::_getTimeValue($timeValue);
|
||||
$timeValue = self::getTimeValue($timeValue);
|
||||
if (is_string($timeValue)) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
}
|
||||
|
@ -1494,12 +1485,12 @@ class PHPExcel_Calculation_DateTime
|
|||
}
|
||||
$adjustmentMonths = floor($adjustmentMonths);
|
||||
|
||||
if (is_string($dateValue = self::_getDateValue($dateValue))) {
|
||||
if (is_string($dateValue = self::getDateValue($dateValue))) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
}
|
||||
|
||||
// Execute function
|
||||
$PHPDateObject = self::_adjustDateByMonths($dateValue, $adjustmentMonths);
|
||||
$PHPDateObject = self::adjustDateByMonths($dateValue, $adjustmentMonths);
|
||||
|
||||
switch (PHPExcel_Calculation_Functions::getReturnDateType()) {
|
||||
case PHPExcel_Calculation_Functions::RETURNDATE_EXCEL:
|
||||
|
@ -1540,12 +1531,12 @@ class PHPExcel_Calculation_DateTime
|
|||
}
|
||||
$adjustmentMonths = floor($adjustmentMonths);
|
||||
|
||||
if (is_string($dateValue = self::_getDateValue($dateValue))) {
|
||||
if (is_string($dateValue = self::getDateValue($dateValue))) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
}
|
||||
|
||||
// Execute function
|
||||
$PHPDateObject = self::_adjustDateByMonths($dateValue, $adjustmentMonths+1);
|
||||
$PHPDateObject = self::adjustDateByMonths($dateValue, $adjustmentMonths+1);
|
||||
$adjustDays = (int) $PHPDateObject->format('d');
|
||||
$adjustDaysString = '-' . $adjustDays . ' days';
|
||||
$PHPDateObject->modify($adjustDaysString);
|
||||
|
|
|
@ -1,6 +1,19 @@
|
|||
<?php
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* PHPExcel
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||
}
|
||||
|
||||
/** EULER */
|
||||
define('EULER', 2.71828182845904523536);
|
||||
|
||||
/**
|
||||
* PHPExcel_Calculation_Engineering
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
|
@ -24,29 +37,6 @@
|
|||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||
}
|
||||
|
||||
|
||||
/** EULER */
|
||||
define('EULER', 2.71828182845904523536);
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Calculation_Engineering
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Calculation
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Calculation_Engineering
|
||||
{
|
||||
/**
|
||||
|
@ -54,7 +44,7 @@ class PHPExcel_Calculation_Engineering
|
|||
*
|
||||
* @var mixed[]
|
||||
*/
|
||||
private static $_conversionUnits = array(
|
||||
private static $conversionUnits = array(
|
||||
'g' => array('Group' => 'Mass', 'Unit Name' => 'Gram', 'AllowPrefix' => true),
|
||||
'sg' => array('Group' => 'Mass', 'Unit Name' => 'Slug', 'AllowPrefix' => false),
|
||||
'lbm' => array('Group' => 'Mass', 'Unit Name' => 'Pound mass (avoirdupois)', 'AllowPrefix' => false),
|
||||
|
@ -125,7 +115,7 @@ class PHPExcel_Calculation_Engineering
|
|||
*
|
||||
* @var mixed[]
|
||||
*/
|
||||
private static $_conversionMultipliers = array(
|
||||
private static $conversionMultipliers = array(
|
||||
'Y' => array('multiplier' => 1E24, 'name' => 'yotta'),
|
||||
'Z' => array('multiplier' => 1E21, 'name' => 'zetta'),
|
||||
'E' => array('multiplier' => 1E18, 'name' => 'exa'),
|
||||
|
@ -153,7 +143,7 @@ class PHPExcel_Calculation_Engineering
|
|||
*
|
||||
* @var mixed[]
|
||||
*/
|
||||
private static $_unitConversions = array(
|
||||
private static $unitConversions = array(
|
||||
'Mass' => array(
|
||||
'g' => array(
|
||||
'g' => 1.0,
|
||||
|
@ -755,14 +745,14 @@ class PHPExcel_Calculation_Engineering
|
|||
|
||||
|
||||
/**
|
||||
* _parseComplex
|
||||
* parseComplex
|
||||
*
|
||||
* Parses a complex number into its real and imaginary parts, and an I or J suffix
|
||||
*
|
||||
* @param string $complexNumber The complex number
|
||||
* @return string[] Indexed on "real", "imaginary" and "suffix"
|
||||
*/
|
||||
public static function _parseComplex($complexNumber)
|
||||
public static function parseComplex($complexNumber)
|
||||
{
|
||||
$workString = (string) $complexNumber;
|
||||
|
||||
|
@ -817,7 +807,7 @@ class PHPExcel_Calculation_Engineering
|
|||
* @param string $complexNumber The complex number to clean
|
||||
* @return string The "cleaned" complex number
|
||||
*/
|
||||
private static function _cleanComplex($complexNumber)
|
||||
private static function cleanComplex($complexNumber)
|
||||
{
|
||||
if ($complexNumber{0} == '+') {
|
||||
$complexNumber = substr($complexNumber, 1);
|
||||
|
@ -841,7 +831,7 @@ class PHPExcel_Calculation_Engineering
|
|||
* @param integer $places The length that we want to pad this value
|
||||
* @return string The padded "number"
|
||||
*/
|
||||
private static function _nbrConversionFormat($xVal, $places)
|
||||
private static function nbrConversionFormat($xVal, $places)
|
||||
{
|
||||
if (!is_null($places)) {
|
||||
if (strlen($xVal) <= $places) {
|
||||
|
@ -964,7 +954,7 @@ class PHPExcel_Calculation_Engineering
|
|||
}
|
||||
|
||||
|
||||
private static function _Besselk0($fNum)
|
||||
private static function besselK0($fNum)
|
||||
{
|
||||
if ($fNum <= 2) {
|
||||
$fNum2 = $fNum * 0.5;
|
||||
|
@ -982,7 +972,7 @@ class PHPExcel_Calculation_Engineering
|
|||
}
|
||||
|
||||
|
||||
private static function _Besselk1($fNum)
|
||||
private static function besselK1($fNum)
|
||||
{
|
||||
if ($fNum <= 2) {
|
||||
$fNum2 = $fNum * 0.5;
|
||||
|
@ -1031,13 +1021,13 @@ class PHPExcel_Calculation_Engineering
|
|||
|
||||
switch(floor($ord)) {
|
||||
case 0:
|
||||
return self::_Besselk0($x);
|
||||
return self::besselK0($x);
|
||||
case 1:
|
||||
return self::_Besselk1($x);
|
||||
return self::besselK1($x);
|
||||
default:
|
||||
$fTox = 2 / $x;
|
||||
$fBkm = self::_Besselk0($x);
|
||||
$fBk = self::_Besselk1($x);
|
||||
$fBkm = self::besselK0($x);
|
||||
$fBk = self::besselK1($x);
|
||||
for ($n = 1; $n < $ord; ++$n) {
|
||||
$fBkp = $fBkm + $n * $fTox * $fBk;
|
||||
$fBkm = $fBk;
|
||||
|
@ -1050,7 +1040,7 @@ class PHPExcel_Calculation_Engineering
|
|||
}
|
||||
|
||||
|
||||
private static function _Bessely0($fNum)
|
||||
private static function besselY0($fNum)
|
||||
{
|
||||
if ($fNum < 8.0) {
|
||||
$y = ($fNum * $fNum);
|
||||
|
@ -1069,7 +1059,7 @@ class PHPExcel_Calculation_Engineering
|
|||
}
|
||||
|
||||
|
||||
private static function _Bessely1($fNum)
|
||||
private static function besselY1($fNum)
|
||||
{
|
||||
if ($fNum < 8.0) {
|
||||
$y = ($fNum * $fNum);
|
||||
|
@ -1115,13 +1105,13 @@ class PHPExcel_Calculation_Engineering
|
|||
|
||||
switch(floor($ord)) {
|
||||
case 0:
|
||||
return self::_Bessely0($x);
|
||||
return self::besselY0($x);
|
||||
case 1:
|
||||
return self::_Bessely1($x);
|
||||
return self::besselY1($x);
|
||||
default:
|
||||
$fTox = 2 / $x;
|
||||
$fBym = self::_Bessely0($x);
|
||||
$fBy = self::_Bessely1($x);
|
||||
$fBym = self::besselY0($x);
|
||||
$fBy = self::besselY1($x);
|
||||
for ($n = 1; $n < $ord; ++$n) {
|
||||
$fByp = $n * $fTox * $fBy - $fBym;
|
||||
$fBym = $fBy;
|
||||
|
@ -1232,7 +1222,7 @@ class PHPExcel_Calculation_Engineering
|
|||
}
|
||||
$hexVal = (string) strtoupper(dechex(bindec($x)));
|
||||
|
||||
return self::_nbrConversionFormat($hexVal, $places);
|
||||
return self::nbrConversionFormat($hexVal, $places);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1287,7 +1277,7 @@ class PHPExcel_Calculation_Engineering
|
|||
}
|
||||
$octVal = (string) decoct(bindec($x));
|
||||
|
||||
return self::_nbrConversionFormat($octVal, $places);
|
||||
return self::nbrConversionFormat($octVal, $places);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1344,7 +1334,7 @@ class PHPExcel_Calculation_Engineering
|
|||
return PHPExcel_Calculation_Functions::NaN();
|
||||
}
|
||||
|
||||
return self::_nbrConversionFormat($r, $places);
|
||||
return self::nbrConversionFormat($r, $places);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1399,7 +1389,7 @@ class PHPExcel_Calculation_Engineering
|
|||
$r = 'FF'.$r;
|
||||
}
|
||||
|
||||
return self::_nbrConversionFormat($r, $places);
|
||||
return self::nbrConversionFormat($r, $places);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1454,7 +1444,7 @@ class PHPExcel_Calculation_Engineering
|
|||
$r = substr($r, -10);
|
||||
}
|
||||
|
||||
return self::_nbrConversionFormat($r, $places);
|
||||
return self::nbrConversionFormat($r, $places);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1503,7 +1493,7 @@ class PHPExcel_Calculation_Engineering
|
|||
}
|
||||
$binVal = decbin(hexdec($x));
|
||||
|
||||
return substr(self::_nbrConversionFormat($binVal, $places), -10);
|
||||
return substr(self::nbrConversionFormat($binVal, $places), -10);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1587,7 +1577,7 @@ class PHPExcel_Calculation_Engineering
|
|||
}
|
||||
$octVal = decoct(hexdec($x));
|
||||
|
||||
return self::_nbrConversionFormat($octVal, $places);
|
||||
return self::nbrConversionFormat($octVal, $places);
|
||||
} // function HEXTOOCT()
|
||||
|
||||
|
||||
|
@ -1639,7 +1629,7 @@ class PHPExcel_Calculation_Engineering
|
|||
}
|
||||
$r = decbin(octdec($x));
|
||||
|
||||
return self::_nbrConversionFormat($r, $places);
|
||||
return self::nbrConversionFormat($r, $places);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1720,7 +1710,7 @@ class PHPExcel_Calculation_Engineering
|
|||
}
|
||||
$hexVal = strtoupper(dechex(octdec($x)));
|
||||
|
||||
return self::_nbrConversionFormat($hexVal, $places);
|
||||
return self::nbrConversionFormat($hexVal, $places);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1798,7 +1788,7 @@ class PHPExcel_Calculation_Engineering
|
|||
{
|
||||
$complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber);
|
||||
|
||||
$parsedComplex = self::_parseComplex($complexNumber);
|
||||
$parsedComplex = self::parseComplex($complexNumber);
|
||||
return $parsedComplex['imaginary'];
|
||||
}
|
||||
|
||||
|
@ -1820,7 +1810,7 @@ class PHPExcel_Calculation_Engineering
|
|||
{
|
||||
$complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber);
|
||||
|
||||
$parsedComplex = self::_parseComplex($complexNumber);
|
||||
$parsedComplex = self::parseComplex($complexNumber);
|
||||
return $parsedComplex['real'];
|
||||
}
|
||||
|
||||
|
@ -1840,7 +1830,7 @@ class PHPExcel_Calculation_Engineering
|
|||
{
|
||||
$complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber);
|
||||
|
||||
$parsedComplex = self::_parseComplex($complexNumber);
|
||||
$parsedComplex = self::parseComplex($complexNumber);
|
||||
|
||||
return sqrt(
|
||||
($parsedComplex['real'] * $parsedComplex['real']) +
|
||||
|
@ -1865,7 +1855,7 @@ class PHPExcel_Calculation_Engineering
|
|||
{
|
||||
$complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber);
|
||||
|
||||
$parsedComplex = self::_parseComplex($complexNumber);
|
||||
$parsedComplex = self::parseComplex($complexNumber);
|
||||
|
||||
if ($parsedComplex['real'] == 0.0) {
|
||||
if ($parsedComplex['imaginary'] == 0.0) {
|
||||
|
@ -1900,12 +1890,12 @@ class PHPExcel_Calculation_Engineering
|
|||
{
|
||||
$complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber);
|
||||
|
||||
$parsedComplex = self::_parseComplex($complexNumber);
|
||||
$parsedComplex = self::parseComplex($complexNumber);
|
||||
|
||||
if ($parsedComplex['imaginary'] == 0.0) {
|
||||
return $parsedComplex['real'];
|
||||
} else {
|
||||
return self::_cleanComplex(
|
||||
return self::cleanComplex(
|
||||
self::COMPLEX(
|
||||
$parsedComplex['real'],
|
||||
0 - $parsedComplex['imaginary'],
|
||||
|
@ -1931,7 +1921,7 @@ class PHPExcel_Calculation_Engineering
|
|||
{
|
||||
$complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber);
|
||||
|
||||
$parsedComplex = self::_parseComplex($complexNumber);
|
||||
$parsedComplex = self::parseComplex($complexNumber);
|
||||
|
||||
if ($parsedComplex['imaginary'] == 0.0) {
|
||||
return cos($parsedComplex['real']);
|
||||
|
@ -1962,7 +1952,7 @@ class PHPExcel_Calculation_Engineering
|
|||
{
|
||||
$complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber);
|
||||
|
||||
$parsedComplex = self::_parseComplex($complexNumber);
|
||||
$parsedComplex = self::parseComplex($complexNumber);
|
||||
|
||||
if ($parsedComplex['imaginary'] == 0.0) {
|
||||
return sin($parsedComplex['real']);
|
||||
|
@ -1991,7 +1981,7 @@ class PHPExcel_Calculation_Engineering
|
|||
{
|
||||
$complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber);
|
||||
|
||||
$parsedComplex = self::_parseComplex($complexNumber);
|
||||
$parsedComplex = self::parseComplex($complexNumber);
|
||||
|
||||
$theta = self::IMARGUMENT($complexNumber);
|
||||
$d1 = cos($theta / 2);
|
||||
|
@ -2021,7 +2011,7 @@ class PHPExcel_Calculation_Engineering
|
|||
{
|
||||
$complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber);
|
||||
|
||||
$parsedComplex = self::_parseComplex($complexNumber);
|
||||
$parsedComplex = self::parseComplex($complexNumber);
|
||||
|
||||
if (($parsedComplex['real'] == 0.0) && ($parsedComplex['imaginary'] == 0.0)) {
|
||||
return PHPExcel_Calculation_Functions::NaN();
|
||||
|
@ -2053,7 +2043,7 @@ class PHPExcel_Calculation_Engineering
|
|||
{
|
||||
$complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber);
|
||||
|
||||
$parsedComplex = self::_parseComplex($complexNumber);
|
||||
$parsedComplex = self::parseComplex($complexNumber);
|
||||
|
||||
if (($parsedComplex['real'] == 0.0) && ($parsedComplex['imaginary'] == 0.0)) {
|
||||
return PHPExcel_Calculation_Functions::NaN();
|
||||
|
@ -2080,7 +2070,7 @@ class PHPExcel_Calculation_Engineering
|
|||
{
|
||||
$complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber);
|
||||
|
||||
$parsedComplex = self::_parseComplex($complexNumber);
|
||||
$parsedComplex = self::parseComplex($complexNumber);
|
||||
|
||||
if (($parsedComplex['real'] == 0.0) && ($parsedComplex['imaginary'] == 0.0)) {
|
||||
return PHPExcel_Calculation_Functions::NaN();
|
||||
|
@ -2107,7 +2097,7 @@ class PHPExcel_Calculation_Engineering
|
|||
{
|
||||
$complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber);
|
||||
|
||||
$parsedComplex = self::_parseComplex($complexNumber);
|
||||
$parsedComplex = self::parseComplex($complexNumber);
|
||||
|
||||
if (($parsedComplex['real'] == 0.0) && ($parsedComplex['imaginary'] == 0.0)) {
|
||||
return '1';
|
||||
|
@ -2146,7 +2136,7 @@ class PHPExcel_Calculation_Engineering
|
|||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
}
|
||||
|
||||
$parsedComplex = self::_parseComplex($complexNumber);
|
||||
$parsedComplex = self::parseComplex($complexNumber);
|
||||
|
||||
$r = sqrt(($parsedComplex['real'] * $parsedComplex['real']) + ($parsedComplex['imaginary'] * $parsedComplex['imaginary']));
|
||||
$rPower = pow($r, $realNumber);
|
||||
|
@ -2178,8 +2168,8 @@ class PHPExcel_Calculation_Engineering
|
|||
$complexDividend = PHPExcel_Calculation_Functions::flattenSingleValue($complexDividend);
|
||||
$complexDivisor = PHPExcel_Calculation_Functions::flattenSingleValue($complexDivisor);
|
||||
|
||||
$parsedComplexDividend = self::_parseComplex($complexDividend);
|
||||
$parsedComplexDivisor = self::_parseComplex($complexDivisor);
|
||||
$parsedComplexDividend = self::parseComplex($complexDividend);
|
||||
$parsedComplexDivisor = self::parseComplex($complexDivisor);
|
||||
|
||||
if (($parsedComplexDividend['suffix'] != '') && ($parsedComplexDivisor['suffix'] != '') &&
|
||||
($parsedComplexDividend['suffix'] != $parsedComplexDivisor['suffix'])) {
|
||||
|
@ -2197,9 +2187,9 @@ class PHPExcel_Calculation_Engineering
|
|||
$i = $d2 / $d3;
|
||||
|
||||
if ($i > 0.0) {
|
||||
return self::_cleanComplex($r.'+'.$i.$parsedComplexDivisor['suffix']);
|
||||
return self::cleanComplex($r.'+'.$i.$parsedComplexDivisor['suffix']);
|
||||
} elseif ($i < 0.0) {
|
||||
return self::_cleanComplex($r.$i.$parsedComplexDivisor['suffix']);
|
||||
return self::cleanComplex($r.$i.$parsedComplexDivisor['suffix']);
|
||||
} else {
|
||||
return $r;
|
||||
}
|
||||
|
@ -2223,8 +2213,8 @@ class PHPExcel_Calculation_Engineering
|
|||
$complexNumber1 = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber1);
|
||||
$complexNumber2 = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber2);
|
||||
|
||||
$parsedComplex1 = self::_parseComplex($complexNumber1);
|
||||
$parsedComplex2 = self::_parseComplex($complexNumber2);
|
||||
$parsedComplex1 = self::parseComplex($complexNumber1);
|
||||
$parsedComplex2 = self::parseComplex($complexNumber2);
|
||||
|
||||
if ((($parsedComplex1['suffix'] != '') && ($parsedComplex2['suffix'] != '')) &&
|
||||
($parsedComplex1['suffix'] != $parsedComplex2['suffix'])) {
|
||||
|
@ -2254,13 +2244,13 @@ class PHPExcel_Calculation_Engineering
|
|||
public static function IMSUM()
|
||||
{
|
||||
// Return value
|
||||
$returnValue = self::_parseComplex('0');
|
||||
$returnValue = self::parseComplex('0');
|
||||
$activeSuffix = '';
|
||||
|
||||
// Loop through the arguments
|
||||
$aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
|
||||
foreach ($aArgs as $arg) {
|
||||
$parsedComplex = self::_parseComplex($arg);
|
||||
$parsedComplex = self::parseComplex($arg);
|
||||
|
||||
if ($activeSuffix == '') {
|
||||
$activeSuffix = $parsedComplex['suffix'];
|
||||
|
@ -2293,13 +2283,13 @@ class PHPExcel_Calculation_Engineering
|
|||
public static function IMPRODUCT()
|
||||
{
|
||||
// Return value
|
||||
$returnValue = self::_parseComplex('1');
|
||||
$returnValue = self::parseComplex('1');
|
||||
$activeSuffix = '';
|
||||
|
||||
// Loop through the arguments
|
||||
$aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
|
||||
foreach ($aArgs as $arg) {
|
||||
$parsedComplex = self::_parseComplex($arg);
|
||||
$parsedComplex = self::parseComplex($arg);
|
||||
|
||||
$workValue = $returnValue;
|
||||
if (($parsedComplex['suffix'] != '') && ($activeSuffix == '')) {
|
||||
|
@ -2369,12 +2359,12 @@ class PHPExcel_Calculation_Engineering
|
|||
//
|
||||
// Private method to calculate the erf value
|
||||
//
|
||||
private static $_two_sqrtpi = 1.128379167095512574;
|
||||
private static $twoSqrtPi = 1.128379167095512574;
|
||||
|
||||
public static function _erfVal($x)
|
||||
public static function erfVal($x)
|
||||
{
|
||||
if (abs($x) > 2.2) {
|
||||
return 1 - self::_erfcVal($x);
|
||||
return 1 - self::erfcVal($x);
|
||||
}
|
||||
$sum = $term = $x;
|
||||
$xsqr = ($x * $x);
|
||||
|
@ -2390,7 +2380,7 @@ class PHPExcel_Calculation_Engineering
|
|||
break;
|
||||
}
|
||||
} while (abs($term / $sum) > PRECISION);
|
||||
return self::$_two_sqrtpi * $sum;
|
||||
return self::$twoSqrtPi * $sum;
|
||||
}
|
||||
|
||||
|
||||
|
@ -2419,10 +2409,10 @@ class PHPExcel_Calculation_Engineering
|
|||
|
||||
if (is_numeric($lower)) {
|
||||
if (is_null($upper)) {
|
||||
return self::_erfVal($lower);
|
||||
return self::erfVal($lower);
|
||||
}
|
||||
if (is_numeric($upper)) {
|
||||
return self::_erfVal($upper) - self::_erfVal($lower);
|
||||
return self::erfVal($upper) - self::erfVal($lower);
|
||||
}
|
||||
}
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
|
@ -2432,12 +2422,12 @@ class PHPExcel_Calculation_Engineering
|
|||
//
|
||||
// Private method to calculate the erfc value
|
||||
//
|
||||
private static $_one_sqrtpi = 0.564189583547756287;
|
||||
private static $oneSqrtPi = 0.564189583547756287;
|
||||
|
||||
private static function _erfcVal($x)
|
||||
private static function erfcVal($x)
|
||||
{
|
||||
if (abs($x) < 2.2) {
|
||||
return 1 - self::_erfVal($x);
|
||||
return 1 - self::erfVal($x);
|
||||
}
|
||||
if ($x < 0) {
|
||||
return 2 - self::ERFC(-$x);
|
||||
|
@ -2458,7 +2448,7 @@ class PHPExcel_Calculation_Engineering
|
|||
$q1 = $q2;
|
||||
$q2 = $b / $d;
|
||||
} while ((abs($q1 - $q2) / $q2) > PRECISION);
|
||||
return self::$_one_sqrtpi * exp(-$x * $x) * $q2;
|
||||
return self::$oneSqrtPi * exp(-$x * $x) * $q2;
|
||||
}
|
||||
|
||||
|
||||
|
@ -2483,7 +2473,7 @@ class PHPExcel_Calculation_Engineering
|
|||
$x = PHPExcel_Calculation_Functions::flattenSingleValue($x);
|
||||
|
||||
if (is_numeric($x)) {
|
||||
return self::_erfcVal($x);
|
||||
return self::erfcVal($x);
|
||||
}
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
}
|
||||
|
@ -2498,7 +2488,7 @@ class PHPExcel_Calculation_Engineering
|
|||
public static function getConversionGroups()
|
||||
{
|
||||
$conversionGroups = array();
|
||||
foreach (self::$_conversionUnits as $conversionUnit) {
|
||||
foreach (self::$conversionUnits as $conversionUnit) {
|
||||
$conversionGroups[] = $conversionUnit['Group'];
|
||||
}
|
||||
return array_merge(array_unique($conversionGroups));
|
||||
|
@ -2515,7 +2505,7 @@ class PHPExcel_Calculation_Engineering
|
|||
public static function getConversionGroupUnits($group = null)
|
||||
{
|
||||
$conversionGroups = array();
|
||||
foreach(self::$_conversionUnits as $conversionUnit => $conversionGroup) {
|
||||
foreach (self::$conversionUnits as $conversionUnit => $conversionGroup) {
|
||||
if ((is_null($group)) || ($conversionGroup['Group'] == $group)) {
|
||||
$conversionGroups[$conversionGroup['Group']][] = $conversionUnit;
|
||||
}
|
||||
|
@ -2533,7 +2523,7 @@ class PHPExcel_Calculation_Engineering
|
|||
public static function getConversionGroupUnitDetails($group = null)
|
||||
{
|
||||
$conversionGroups = array();
|
||||
foreach(self::$_conversionUnits as $conversionUnit => $conversionGroup) {
|
||||
foreach (self::$conversionUnits as $conversionUnit => $conversionGroup) {
|
||||
if ((is_null($group)) || ($conversionGroup['Group'] == $group)) {
|
||||
$conversionGroups[$conversionGroup['Group']][] = array(
|
||||
'unit' => $conversionUnit,
|
||||
|
@ -2553,7 +2543,7 @@ class PHPExcel_Calculation_Engineering
|
|||
*/
|
||||
public static function getConversionMultipliers()
|
||||
{
|
||||
return self::$_conversionMultipliers;
|
||||
return self::$conversionMultipliers;
|
||||
}
|
||||
|
||||
|
||||
|
@ -2583,18 +2573,18 @@ class PHPExcel_Calculation_Engineering
|
|||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
}
|
||||
$fromMultiplier = 1.0;
|
||||
if (isset(self::$_conversionUnits[$fromUOM])) {
|
||||
$unitGroup1 = self::$_conversionUnits[$fromUOM]['Group'];
|
||||
if (isset(self::$conversionUnits[$fromUOM])) {
|
||||
$unitGroup1 = self::$conversionUnits[$fromUOM]['Group'];
|
||||
} else {
|
||||
$fromMultiplier = substr($fromUOM, 0, 1);
|
||||
$fromUOM = substr($fromUOM, 1);
|
||||
if (isset(self::$_conversionMultipliers[$fromMultiplier])) {
|
||||
$fromMultiplier = self::$_conversionMultipliers[$fromMultiplier]['multiplier'];
|
||||
if (isset(self::$conversionMultipliers[$fromMultiplier])) {
|
||||
$fromMultiplier = self::$conversionMultipliers[$fromMultiplier]['multiplier'];
|
||||
} else {
|
||||
return PHPExcel_Calculation_Functions::NA();
|
||||
}
|
||||
if ((isset(self::$_conversionUnits[$fromUOM])) && (self::$_conversionUnits[$fromUOM]['AllowPrefix'])) {
|
||||
$unitGroup1 = self::$_conversionUnits[$fromUOM]['Group'];
|
||||
if ((isset(self::$conversionUnits[$fromUOM])) && (self::$conversionUnits[$fromUOM]['AllowPrefix'])) {
|
||||
$unitGroup1 = self::$conversionUnits[$fromUOM]['Group'];
|
||||
} else {
|
||||
return PHPExcel_Calculation_Functions::NA();
|
||||
}
|
||||
|
@ -2602,18 +2592,18 @@ class PHPExcel_Calculation_Engineering
|
|||
$value *= $fromMultiplier;
|
||||
|
||||
$toMultiplier = 1.0;
|
||||
if (isset(self::$_conversionUnits[$toUOM])) {
|
||||
$unitGroup2 = self::$_conversionUnits[$toUOM]['Group'];
|
||||
if (isset(self::$conversionUnits[$toUOM])) {
|
||||
$unitGroup2 = self::$conversionUnits[$toUOM]['Group'];
|
||||
} else {
|
||||
$toMultiplier = substr($toUOM, 0, 1);
|
||||
$toUOM = substr($toUOM, 1);
|
||||
if (isset(self::$_conversionMultipliers[$toMultiplier])) {
|
||||
$toMultiplier = self::$_conversionMultipliers[$toMultiplier]['multiplier'];
|
||||
if (isset(self::$conversionMultipliers[$toMultiplier])) {
|
||||
$toMultiplier = self::$conversionMultipliers[$toMultiplier]['multiplier'];
|
||||
} else {
|
||||
return PHPExcel_Calculation_Functions::NA();
|
||||
}
|
||||
if ((isset(self::$_conversionUnits[$toUOM])) && (self::$_conversionUnits[$toUOM]['AllowPrefix'])) {
|
||||
$unitGroup2 = self::$_conversionUnits[$toUOM]['Group'];
|
||||
if ((isset(self::$conversionUnits[$toUOM])) && (self::$conversionUnits[$toUOM]['AllowPrefix'])) {
|
||||
$unitGroup2 = self::$conversionUnits[$toUOM]['Group'];
|
||||
} else {
|
||||
return PHPExcel_Calculation_Functions::NA();
|
||||
}
|
||||
|
@ -2655,6 +2645,6 @@ class PHPExcel_Calculation_Engineering
|
|||
}
|
||||
return $value + 273.15;
|
||||
}
|
||||
return ($value * self::$_unitConversions[$unitGroup1][$fromUOM][$toUOM]) / $toMultiplier;
|
||||
return ($value * self::$unitConversions[$unitGroup1][$fromUOM][$toUOM]) / $toMultiplier;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PHPExcel
|
||||
* PHPExcel_Calculation_Exception
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
|
@ -24,16 +25,8 @@
|
|||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Calculation_Exception
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Calculation
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Calculation_Exception extends PHPExcel_Exception {
|
||||
class PHPExcel_Calculation_Exception extends PHPExcel_Exception
|
||||
{
|
||||
/**
|
||||
* Error handler callback
|
||||
*
|
||||
|
@ -43,7 +36,8 @@ class PHPExcel_Calculation_Exception extends PHPExcel_Exception {
|
|||
* @param mixed $line
|
||||
* @param mixed $context
|
||||
*/
|
||||
public static function errorHandlerCallback($code, $string, $file, $line, $context) {
|
||||
public static function errorHandlerCallback($code, $string, $file, $line, $context)
|
||||
{
|
||||
$e = new self($string, $code);
|
||||
$e->line = $line;
|
||||
$e->file = $file;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PHPExcel
|
||||
* PHPExcel_Calculation_ExceptionHandler
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
|
@ -24,26 +25,21 @@
|
|||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/**
|
||||
* PHPExcel_Calculation_ExceptionHandler
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Calculation
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Calculation_ExceptionHandler {
|
||||
class PHPExcel_Calculation_ExceptionHandler
|
||||
{
|
||||
/**
|
||||
* Register errorhandler
|
||||
*/
|
||||
public function __construct() {
|
||||
public function __construct()
|
||||
{
|
||||
set_error_handler(array('PHPExcel_Calculation_Exception', 'errorHandlerCallback'), E_ALL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister errorhandler
|
||||
*/
|
||||
public function __destruct() {
|
||||
public function __destruct()
|
||||
{
|
||||
restore_error_handler();
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,30 +1,4 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Calculation
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
PARTLY BASED ON:
|
||||
|
@ -52,11 +26,32 @@ PARTLY BASED ON:
|
|||
/**
|
||||
* PHPExcel_Calculation_FormulaParser
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Calculation
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
class PHPExcel_Calculation_FormulaParser {
|
||||
|
||||
|
||||
class PHPExcel_Calculation_FormulaParser
|
||||
{
|
||||
/* Character constants */
|
||||
const QUOTE_DOUBLE = '"';
|
||||
const QUOTE_SINGLE = '\'';
|
||||
|
@ -80,14 +75,14 @@ class PHPExcel_Calculation_FormulaParser {
|
|||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_formula;
|
||||
private $formula;
|
||||
|
||||
/**
|
||||
* Tokens
|
||||
*
|
||||
* @var PHPExcel_Calculation_FormulaToken[]
|
||||
*/
|
||||
private $_tokens = array();
|
||||
private $tokens = array();
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_Calculation_FormulaParser
|
||||
|
@ -103,9 +98,9 @@ class PHPExcel_Calculation_FormulaParser {
|
|||
}
|
||||
|
||||
// Initialise values
|
||||
$this->_formula = trim($pFormula);
|
||||
$this->formula = trim($pFormula);
|
||||
// Parse!
|
||||
$this->_parseToTokens();
|
||||
$this->parseToTokens();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -113,8 +108,9 @@ class PHPExcel_Calculation_FormulaParser {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFormula() {
|
||||
return $this->_formula;
|
||||
public function getFormula()
|
||||
{
|
||||
return $this->formula;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -124,9 +120,10 @@ class PHPExcel_Calculation_FormulaParser {
|
|||
* @return string
|
||||
* @throws PHPExcel_Calculation_Exception
|
||||
*/
|
||||
public function getToken($pId = 0) {
|
||||
if (isset($this->_tokens[$pId])) {
|
||||
return $this->_tokens[$pId];
|
||||
public function getToken($pId = 0)
|
||||
{
|
||||
if (isset($this->tokens[$pId])) {
|
||||
return $this->tokens[$pId];
|
||||
} else {
|
||||
throw new PHPExcel_Calculation_Exception("Token with id $pId does not exist.");
|
||||
}
|
||||
|
@ -137,8 +134,9 @@ class PHPExcel_Calculation_FormulaParser {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTokenCount() {
|
||||
return count($this->_tokens);
|
||||
public function getTokenCount()
|
||||
{
|
||||
return count($this->tokens);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -146,20 +144,24 @@ class PHPExcel_Calculation_FormulaParser {
|
|||
*
|
||||
* @return PHPExcel_Calculation_FormulaToken[]
|
||||
*/
|
||||
public function getTokens() {
|
||||
return $this->_tokens;
|
||||
public function getTokens()
|
||||
{
|
||||
return $this->tokens;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse to tokens
|
||||
*/
|
||||
private function _parseToTokens() {
|
||||
private function parseToTokens()
|
||||
{
|
||||
// No attempt is made to verify formulas; assumes formulas are derived from Excel, where
|
||||
// they can only exist if valid; stack overflows/underflows sunk as nulls without exceptions.
|
||||
|
||||
// Check if the formula has a valid starting =
|
||||
$formulaLength = strlen($this->_formula);
|
||||
if ($formulaLength < 2 || $this->_formula{0} != '=') return;
|
||||
$formulaLength = strlen($this->formula);
|
||||
if ($formulaLength < 2 || $this->formula{0} != '=') {
|
||||
return;
|
||||
}
|
||||
|
||||
// Helper variables
|
||||
$tokens1 = $tokens2 = $stack = array();
|
||||
|
@ -179,8 +181,8 @@ class PHPExcel_Calculation_FormulaParser {
|
|||
// embeds are doubled
|
||||
// end marks token
|
||||
if ($inString) {
|
||||
if ($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::QUOTE_DOUBLE) {
|
||||
if ((($index + 2) <= $formulaLength) && ($this->_formula{$index + 1} == PHPExcel_Calculation_FormulaParser::QUOTE_DOUBLE)) {
|
||||
if ($this->formula{$index} == PHPExcel_Calculation_FormulaParser::QUOTE_DOUBLE) {
|
||||
if ((($index + 2) <= $formulaLength) && ($this->formula{$index + 1} == PHPExcel_Calculation_FormulaParser::QUOTE_DOUBLE)) {
|
||||
$value .= PHPExcel_Calculation_FormulaParser::QUOTE_DOUBLE;
|
||||
++$index;
|
||||
} else {
|
||||
|
@ -189,7 +191,7 @@ class PHPExcel_Calculation_FormulaParser {
|
|||
$value = "";
|
||||
}
|
||||
} else {
|
||||
$value .= $this->_formula{$index};
|
||||
$value .= $this->formula{$index};
|
||||
}
|
||||
++$index;
|
||||
continue;
|
||||
|
@ -199,15 +201,15 @@ class PHPExcel_Calculation_FormulaParser {
|
|||
// embeds are double
|
||||
// end does not mark a token
|
||||
if ($inPath) {
|
||||
if ($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::QUOTE_SINGLE) {
|
||||
if ((($index + 2) <= $formulaLength) && ($this->_formula{$index + 1} == PHPExcel_Calculation_FormulaParser::QUOTE_SINGLE)) {
|
||||
if ($this->formula{$index} == PHPExcel_Calculation_FormulaParser::QUOTE_SINGLE) {
|
||||
if ((($index + 2) <= $formulaLength) && ($this->formula{$index + 1} == PHPExcel_Calculation_FormulaParser::QUOTE_SINGLE)) {
|
||||
$value .= PHPExcel_Calculation_FormulaParser::QUOTE_SINGLE;
|
||||
++$index;
|
||||
} else {
|
||||
$inPath = false;
|
||||
}
|
||||
} else {
|
||||
$value .= $this->_formula{$index};
|
||||
$value .= $this->formula{$index};
|
||||
}
|
||||
++$index;
|
||||
continue;
|
||||
|
@ -217,10 +219,10 @@ class PHPExcel_Calculation_FormulaParser {
|
|||
// no embeds (changed to "()" by Excel)
|
||||
// end does not mark a token
|
||||
if ($inRange) {
|
||||
if ($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::BRACKET_CLOSE) {
|
||||
if ($this->formula{$index} == PHPExcel_Calculation_FormulaParser::BRACKET_CLOSE) {
|
||||
$inRange = false;
|
||||
}
|
||||
$value .= $this->_formula{$index};
|
||||
$value .= $this->formula{$index};
|
||||
++$index;
|
||||
continue;
|
||||
}
|
||||
|
@ -228,7 +230,7 @@ class PHPExcel_Calculation_FormulaParser {
|
|||
// error values
|
||||
// end marks a token, determined from absolute list of values
|
||||
if ($inError) {
|
||||
$value .= $this->_formula{$index};
|
||||
$value .= $this->formula{$index};
|
||||
++$index;
|
||||
if (in_array($value, $ERRORS)) {
|
||||
$inError = false;
|
||||
|
@ -239,10 +241,10 @@ class PHPExcel_Calculation_FormulaParser {
|
|||
}
|
||||
|
||||
// scientific notation check
|
||||
if (strpos(PHPExcel_Calculation_FormulaParser::OPERATORS_SN, $this->_formula{$index}) !== false) {
|
||||
if (strpos(PHPExcel_Calculation_FormulaParser::OPERATORS_SN, $this->formula{$index}) !== false) {
|
||||
if (strlen($value) > 1) {
|
||||
if (preg_match("/^[1-9]{1}(\.[0-9]+)?E{1}$/", $this->_formula{$index}) != 0) {
|
||||
$value .= $this->_formula{$index};
|
||||
if (preg_match("/^[1-9]{1}(\.[0-9]+)?E{1}$/", $this->formula{$index}) != 0) {
|
||||
$value .= $this->formula{$index};
|
||||
++$index;
|
||||
continue;
|
||||
}
|
||||
|
@ -252,8 +254,9 @@ class PHPExcel_Calculation_FormulaParser {
|
|||
// independent character evaluation (order not important)
|
||||
|
||||
// establish state-dependent character evaluations
|
||||
if ($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::QUOTE_DOUBLE) {
|
||||
if (strlen($value > 0)) { // unexpected
|
||||
if ($this->formula{$index} == PHPExcel_Calculation_FormulaParser::QUOTE_DOUBLE) {
|
||||
if (strlen($value > 0)) {
|
||||
// unexpected
|
||||
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_UNKNOWN);
|
||||
$value = "";
|
||||
}
|
||||
|
@ -262,8 +265,9 @@ class PHPExcel_Calculation_FormulaParser {
|
|||
continue;
|
||||
}
|
||||
|
||||
if ($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::QUOTE_SINGLE) {
|
||||
if (strlen($value) > 0) { // unexpected
|
||||
if ($this->formula{$index} == PHPExcel_Calculation_FormulaParser::QUOTE_SINGLE) {
|
||||
if (strlen($value) > 0) {
|
||||
// unexpected
|
||||
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_UNKNOWN);
|
||||
$value = "";
|
||||
}
|
||||
|
@ -272,15 +276,16 @@ class PHPExcel_Calculation_FormulaParser {
|
|||
continue;
|
||||
}
|
||||
|
||||
if ($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::BRACKET_OPEN) {
|
||||
if ($this->formula{$index} == PHPExcel_Calculation_FormulaParser::BRACKET_OPEN) {
|
||||
$inRange = true;
|
||||
$value .= PHPExcel_Calculation_FormulaParser::BRACKET_OPEN;
|
||||
++$index;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::ERROR_START) {
|
||||
if (strlen($value) > 0) { // unexpected
|
||||
if ($this->formula{$index} == PHPExcel_Calculation_FormulaParser::ERROR_START) {
|
||||
if (strlen($value) > 0) {
|
||||
// unexpected
|
||||
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_UNKNOWN);
|
||||
$value = "";
|
||||
}
|
||||
|
@ -291,8 +296,9 @@ class PHPExcel_Calculation_FormulaParser {
|
|||
}
|
||||
|
||||
// mark start and end of arrays and array rows
|
||||
if ($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::BRACE_OPEN) {
|
||||
if (strlen($value) > 0) { // unexpected
|
||||
if ($this->formula{$index} == PHPExcel_Calculation_FormulaParser::BRACE_OPEN) {
|
||||
if (strlen($value) > 0) {
|
||||
// unexpected
|
||||
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_UNKNOWN);
|
||||
$value = "";
|
||||
}
|
||||
|
@ -309,7 +315,7 @@ class PHPExcel_Calculation_FormulaParser {
|
|||
continue;
|
||||
}
|
||||
|
||||
if ($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::SEMICOLON) {
|
||||
if ($this->formula{$index} == PHPExcel_Calculation_FormulaParser::SEMICOLON) {
|
||||
if (strlen($value) > 0) {
|
||||
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
|
||||
$value = "";
|
||||
|
@ -331,7 +337,7 @@ class PHPExcel_Calculation_FormulaParser {
|
|||
continue;
|
||||
}
|
||||
|
||||
if ($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::BRACE_CLOSE) {
|
||||
if ($this->formula{$index} == PHPExcel_Calculation_FormulaParser::BRACE_CLOSE) {
|
||||
if (strlen($value) > 0) {
|
||||
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
|
||||
$value = "";
|
||||
|
@ -352,14 +358,14 @@ class PHPExcel_Calculation_FormulaParser {
|
|||
}
|
||||
|
||||
// trim white-space
|
||||
if ($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::WHITESPACE) {
|
||||
if ($this->formula{$index} == PHPExcel_Calculation_FormulaParser::WHITESPACE) {
|
||||
if (strlen($value) > 0) {
|
||||
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
|
||||
$value = "";
|
||||
}
|
||||
$tokens1[] = new PHPExcel_Calculation_FormulaToken("", PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_WHITESPACE);
|
||||
++$index;
|
||||
while (($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::WHITESPACE) && ($index < $formulaLength)) {
|
||||
while (($this->formula{$index} == PHPExcel_Calculation_FormulaParser::WHITESPACE) && ($index < $formulaLength)) {
|
||||
++$index;
|
||||
}
|
||||
continue;
|
||||
|
@ -367,41 +373,41 @@ class PHPExcel_Calculation_FormulaParser {
|
|||
|
||||
// multi-character comparators
|
||||
if (($index + 2) <= $formulaLength) {
|
||||
if (in_array(substr($this->_formula, $index, 2), $COMPARATORS_MULTI)) {
|
||||
if (in_array(substr($this->formula, $index, 2), $COMPARATORS_MULTI)) {
|
||||
if (strlen($value) > 0) {
|
||||
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
|
||||
$value = "";
|
||||
}
|
||||
$tokens1[] = new PHPExcel_Calculation_FormulaToken(substr($this->_formula, $index, 2), PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORINFIX, PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_LOGICAL);
|
||||
$tokens1[] = new PHPExcel_Calculation_FormulaToken(substr($this->formula, $index, 2), PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORINFIX, PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_LOGICAL);
|
||||
$index += 2;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// standard infix operators
|
||||
if (strpos(PHPExcel_Calculation_FormulaParser::OPERATORS_INFIX, $this->_formula{$index}) !== false) {
|
||||
if (strpos(PHPExcel_Calculation_FormulaParser::OPERATORS_INFIX, $this->formula{$index}) !== false) {
|
||||
if (strlen($value) > 0) {
|
||||
$tokens1[] =new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
|
||||
$value = "";
|
||||
}
|
||||
$tokens1[] = new PHPExcel_Calculation_FormulaToken($this->_formula{$index}, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORINFIX);
|
||||
$tokens1[] = new PHPExcel_Calculation_FormulaToken($this->formula{$index}, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORINFIX);
|
||||
++$index;
|
||||
continue;
|
||||
}
|
||||
|
||||
// standard postfix operators (only one)
|
||||
if (strpos(PHPExcel_Calculation_FormulaParser::OPERATORS_POSTFIX, $this->_formula{$index}) !== false) {
|
||||
if (strpos(PHPExcel_Calculation_FormulaParser::OPERATORS_POSTFIX, $this->formula{$index}) !== false) {
|
||||
if (strlen($value) > 0) {
|
||||
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
|
||||
$value = "";
|
||||
}
|
||||
$tokens1[] = new PHPExcel_Calculation_FormulaToken($this->_formula{$index}, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORPOSTFIX);
|
||||
$tokens1[] = new PHPExcel_Calculation_FormulaToken($this->formula{$index}, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORPOSTFIX);
|
||||
++$index;
|
||||
continue;
|
||||
}
|
||||
|
||||
// start subexpression or function
|
||||
if ($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::PAREN_OPEN) {
|
||||
if ($this->formula{$index} == PHPExcel_Calculation_FormulaParser::PAREN_OPEN) {
|
||||
if (strlen($value) > 0) {
|
||||
$tmp = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_FUNCTION, PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_START);
|
||||
$tokens1[] = $tmp;
|
||||
|
@ -417,7 +423,7 @@ class PHPExcel_Calculation_FormulaParser {
|
|||
}
|
||||
|
||||
// function, subexpression, or array parameters, or operand unions
|
||||
if ($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::COMMA) {
|
||||
if ($this->formula{$index} == PHPExcel_Calculation_FormulaParser::COMMA) {
|
||||
if (strlen($value) > 0) {
|
||||
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
|
||||
$value = "";
|
||||
|
@ -438,7 +444,7 @@ class PHPExcel_Calculation_FormulaParser {
|
|||
}
|
||||
|
||||
// stop subexpression
|
||||
if ($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::PAREN_CLOSE) {
|
||||
if ($this->formula{$index} == PHPExcel_Calculation_FormulaParser::PAREN_CLOSE) {
|
||||
if (strlen($value) > 0) {
|
||||
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
|
||||
$value = "";
|
||||
|
@ -454,7 +460,7 @@ class PHPExcel_Calculation_FormulaParser {
|
|||
}
|
||||
|
||||
// token accumulation
|
||||
$value .= $this->_formula{$index};
|
||||
$value .= $this->formula{$index};
|
||||
++$index;
|
||||
}
|
||||
|
||||
|
@ -516,7 +522,7 @@ class PHPExcel_Calculation_FormulaParser {
|
|||
|
||||
// move tokens to final list, switching infix "-" operators to prefix when appropriate, switching infix "+" operators
|
||||
// to noop when appropriate, identifying operand and infix-operator subtypes, and pulling "@" from function names
|
||||
$this->_tokens = array();
|
||||
$this->tokens = array();
|
||||
|
||||
$tokenCount = count($tokens2);
|
||||
for ($i = 0; $i < $tokenCount; ++$i) {
|
||||
|
@ -539,40 +545,41 @@ class PHPExcel_Calculation_FormulaParser {
|
|||
if ($token->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORINFIX && $token->getValue() == "-") {
|
||||
if ($i == 0) {
|
||||
$token->setTokenType(PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORPREFIX);
|
||||
} else if (
|
||||
(($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_FUNCTION) && ($previousToken->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_STOP)) ||
|
||||
(($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_SUBEXPRESSION) && ($previousToken->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_STOP)) ||
|
||||
} elseif ((($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_FUNCTION) &&
|
||||
($previousToken->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_STOP)) ||
|
||||
(($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_SUBEXPRESSION) &&
|
||||
($previousToken->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_STOP)) ||
|
||||
($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORPOSTFIX) ||
|
||||
($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND)
|
||||
) {
|
||||
($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND)) {
|
||||
$token->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_MATH);
|
||||
} else {
|
||||
$token->setTokenType(PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORPREFIX);
|
||||
}
|
||||
|
||||
$this->_tokens[] = $token;
|
||||
$this->tokens[] = $token;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($token->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORINFIX && $token->getValue() == "+") {
|
||||
if ($i == 0) {
|
||||
continue;
|
||||
} else if (
|
||||
(($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_FUNCTION) && ($previousToken->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_STOP)) ||
|
||||
(($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_SUBEXPRESSION) && ($previousToken->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_STOP)) ||
|
||||
} elseif ((($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_FUNCTION) &&
|
||||
($previousToken->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_STOP)) ||
|
||||
(($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_SUBEXPRESSION) &&
|
||||
($previousToken->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_STOP)) ||
|
||||
($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORPOSTFIX) ||
|
||||
($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND)
|
||||
) {
|
||||
($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND)) {
|
||||
$token->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_MATH);
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->_tokens[] = $token;
|
||||
$this->tokens[] = $token;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($token->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORINFIX && $token->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_NOTHING) {
|
||||
if ($token->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORINFIX &&
|
||||
$token->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_NOTHING) {
|
||||
if (strpos("<>=", substr($token->getValue(), 0, 1)) !== false) {
|
||||
$token->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_LOGICAL);
|
||||
} elseif ($token->getValue() == "&") {
|
||||
|
@ -581,11 +588,12 @@ class PHPExcel_Calculation_FormulaParser {
|
|||
$token->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_MATH);
|
||||
}
|
||||
|
||||
$this->_tokens[] = $token;
|
||||
$this->tokens[] = $token;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($token->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND && $token->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_NOTHING) {
|
||||
if ($token->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND &&
|
||||
$token->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_NOTHING) {
|
||||
if (!is_numeric($token->getValue())) {
|
||||
if (strtoupper($token->getValue()) == "TRUE" || strtoupper($token->getValue() == "FALSE")) {
|
||||
$token->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_LOGICAL);
|
||||
|
@ -596,7 +604,7 @@ class PHPExcel_Calculation_FormulaParser {
|
|||
$token->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_NUMBER);
|
||||
}
|
||||
|
||||
$this->_tokens[] = $token;
|
||||
$this->tokens[] = $token;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -608,7 +616,7 @@ class PHPExcel_Calculation_FormulaParser {
|
|||
}
|
||||
}
|
||||
|
||||
$this->_tokens[] = $token;
|
||||
$this->tokens[] = $token;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,30 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
PARTLY BASED ON:
|
||||
Copyright (c) 2007 E. W. Bachtal, Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
||||
and associated documentation files (the "Software"), to deal in the Software without restriction,
|
||||
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial
|
||||
portions of the Software.
|
||||
|
||||
The software is provided "as is", without warranty of any kind, express or implied, including but not
|
||||
limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In
|
||||
no event shall the authors or copyright holders be liable for any claim, damages or other liability,
|
||||
whether in an action of contract, tort or otherwise, arising from, out of or in connection with the
|
||||
software or the use or other dealings in the software.
|
||||
|
||||
http://ewbi.blogs.com/develops/2007/03/excel_formula_p.html
|
||||
http://ewbi.blogs.com/develops/2004/12/excel_formula_p.html
|
||||
*/
|
||||
|
||||
/**
|
||||
* PHPExcel
|
||||
* PHPExcel_Calculation_FormulaToken
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
|
@ -26,38 +50,8 @@
|
|||
*/
|
||||
|
||||
|
||||
/*
|
||||
PARTLY BASED ON:
|
||||
Copyright (c) 2007 E. W. Bachtal, Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
||||
and associated documentation files (the "Software"), to deal in the Software without restriction,
|
||||
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial
|
||||
portions of the Software.
|
||||
|
||||
The software is provided "as is", without warranty of any kind, express or implied, including but not
|
||||
limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In
|
||||
no event shall the authors or copyright holders be liable for any claim, damages or other liability,
|
||||
whether in an action of contract, tort or otherwise, arising from, out of or in connection with the
|
||||
software or the use or other dealings in the software.
|
||||
|
||||
http://ewbi.blogs.com/develops/2007/03/excel_formula_p.html
|
||||
http://ewbi.blogs.com/develops/2004/12/excel_formula_p.html
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Calculation_FormulaToken
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Calculation
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Calculation_FormulaToken {
|
||||
class PHPExcel_Calculation_FormulaToken
|
||||
{
|
||||
/* Token types */
|
||||
const TOKEN_TYPE_NOOP = 'Noop';
|
||||
const TOKEN_TYPE_OPERAND = 'Operand';
|
||||
|
@ -89,21 +83,21 @@ class PHPExcel_Calculation_FormulaToken {
|
|||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_value;
|
||||
private $value;
|
||||
|
||||
/**
|
||||
* Token Type (represented by TOKEN_TYPE_*)
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_tokenType;
|
||||
private $tokenType;
|
||||
|
||||
/**
|
||||
* Token SubType (represented by TOKEN_SUBTYPE_*)
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_tokenSubType;
|
||||
private $tokenSubType;
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_Calculation_FormulaToken
|
||||
|
@ -115,9 +109,9 @@ class PHPExcel_Calculation_FormulaToken {
|
|||
public function __construct($pValue, $pTokenType = PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_UNKNOWN, $pTokenSubType = PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_NOTHING)
|
||||
{
|
||||
// Initialise values
|
||||
$this->_value = $pValue;
|
||||
$this->_tokenType = $pTokenType;
|
||||
$this->_tokenSubType = $pTokenSubType;
|
||||
$this->value = $pValue;
|
||||
$this->tokenType = $pTokenType;
|
||||
$this->tokenSubType = $pTokenSubType;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -125,8 +119,9 @@ class PHPExcel_Calculation_FormulaToken {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getValue() {
|
||||
return $this->_value;
|
||||
public function getValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -134,8 +129,9 @@ class PHPExcel_Calculation_FormulaToken {
|
|||
*
|
||||
* @param string $value
|
||||
*/
|
||||
public function setValue($value) {
|
||||
$this->_value = $value;
|
||||
public function setValue($value)
|
||||
{
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -143,8 +139,9 @@ class PHPExcel_Calculation_FormulaToken {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTokenType() {
|
||||
return $this->_tokenType;
|
||||
public function getTokenType()
|
||||
{
|
||||
return $this->tokenType;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -152,8 +149,9 @@ class PHPExcel_Calculation_FormulaToken {
|
|||
*
|
||||
* @param string $value
|
||||
*/
|
||||
public function setTokenType($value = PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_UNKNOWN) {
|
||||
$this->_tokenType = $value;
|
||||
public function setTokenType($value = PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_UNKNOWN)
|
||||
{
|
||||
$this->tokenType = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -161,8 +159,9 @@ class PHPExcel_Calculation_FormulaToken {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTokenSubType() {
|
||||
return $this->_tokenSubType;
|
||||
public function getTokenSubType()
|
||||
{
|
||||
return $this->tokenSubType;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -170,7 +169,8 @@ class PHPExcel_Calculation_FormulaToken {
|
|||
*
|
||||
* @param string $value
|
||||
*/
|
||||
public function setTokenSubType($value = PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_NOTHING) {
|
||||
$this->_tokenSubType = $value;
|
||||
public function setTokenSubType($value = PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_NOTHING)
|
||||
{
|
||||
$this->tokenSubType = $value;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PHPExcel
|
||||
* PHPExcel_Calculation_Function
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
|
@ -24,16 +25,8 @@
|
|||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Calculation_Function
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Calculation
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Calculation_Function {
|
||||
class PHPExcel_Calculation_Function
|
||||
{
|
||||
/* Function categories */
|
||||
const CATEGORY_CUBE = 'Cube';
|
||||
const CATEGORY_DATABASE = 'Database';
|
||||
|
@ -52,21 +45,21 @@ class PHPExcel_Calculation_Function {
|
|||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_category;
|
||||
private $category;
|
||||
|
||||
/**
|
||||
* Excel name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_excelName;
|
||||
private $excelName;
|
||||
|
||||
/**
|
||||
* PHPExcel name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_phpExcelName;
|
||||
private $phpExcelName;
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_Calculation_Function
|
||||
|
@ -76,13 +69,13 @@ class PHPExcel_Calculation_Function {
|
|||
* @param string $pPHPExcelName PHPExcel function mapping
|
||||
* @throws PHPExcel_Calculation_Exception
|
||||
*/
|
||||
public function __construct($pCategory = NULL, $pExcelName = NULL, $pPHPExcelName = NULL)
|
||||
public function __construct($pCategory = null, $pExcelName = null, $pPHPExcelName = null)
|
||||
{
|
||||
if (($pCategory !== NULL) && ($pExcelName !== NULL) && ($pPHPExcelName !== NULL)) {
|
||||
if (($pCategory !== null) && ($pExcelName !== null) && ($pPHPExcelName !== null)) {
|
||||
// Initialise values
|
||||
$this->_category = $pCategory;
|
||||
$this->_excelName = $pExcelName;
|
||||
$this->_phpExcelName = $pPHPExcelName;
|
||||
$this->category = $pCategory;
|
||||
$this->excelName = $pExcelName;
|
||||
$this->phpExcelName = $pPHPExcelName;
|
||||
} else {
|
||||
throw new PHPExcel_Calculation_Exception("Invalid parameters passed.");
|
||||
}
|
||||
|
@ -93,8 +86,9 @@ class PHPExcel_Calculation_Function {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCategory() {
|
||||
return $this->_category;
|
||||
public function getCategory()
|
||||
{
|
||||
return $this->category;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -103,9 +97,10 @@ class PHPExcel_Calculation_Function {
|
|||
* @param string $value
|
||||
* @throws PHPExcel_Calculation_Exception
|
||||
*/
|
||||
public function setCategory($value = null) {
|
||||
public function setCategory($value = null)
|
||||
{
|
||||
if (!is_null($value)) {
|
||||
$this->_category = $value;
|
||||
$this->category = $value;
|
||||
} else {
|
||||
throw new PHPExcel_Calculation_Exception("Invalid parameter passed.");
|
||||
}
|
||||
|
@ -116,8 +111,9 @@ class PHPExcel_Calculation_Function {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getExcelName() {
|
||||
return $this->_excelName;
|
||||
public function getExcelName()
|
||||
{
|
||||
return $this->excelName;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -125,8 +121,9 @@ class PHPExcel_Calculation_Function {
|
|||
*
|
||||
* @param string $value
|
||||
*/
|
||||
public function setExcelName($value) {
|
||||
$this->_excelName = $value;
|
||||
public function setExcelName($value)
|
||||
{
|
||||
$this->excelName = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -134,8 +131,9 @@ class PHPExcel_Calculation_Function {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPHPExcelName() {
|
||||
return $this->_phpExcelName;
|
||||
public function getPHPExcelName()
|
||||
{
|
||||
return $this->phpExcelName;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -143,7 +141,8 @@ class PHPExcel_Calculation_Function {
|
|||
*
|
||||
* @param string $value
|
||||
*/
|
||||
public function setPHPExcelName($value) {
|
||||
$this->_phpExcelName = $value;
|
||||
public function setPHPExcelName($value)
|
||||
{
|
||||
$this->phpExcelName = $value;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,30 +1,4 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Calculation
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
|
@ -52,11 +26,30 @@ define('PRECISION', 8.88E-016);
|
|||
/**
|
||||
* PHPExcel_Calculation_Functions
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Calculation
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
class PHPExcel_Calculation_Functions {
|
||||
class PHPExcel_Calculation_Functions
|
||||
{
|
||||
|
||||
/** constants */
|
||||
const COMPATIBILITY_EXCEL = 'Excel';
|
||||
|
@ -90,7 +83,8 @@ class PHPExcel_Calculation_Functions {
|
|||
* @access private
|
||||
* @var array
|
||||
*/
|
||||
protected static $_errorCodes = array( 'null' => '#NULL!',
|
||||
protected static $_errorCodes = array(
|
||||
'null' => '#NULL!',
|
||||
'divisionbyzero' => '#DIV/0!',
|
||||
'value' => '#VALUE!',
|
||||
'reference' => '#REF!',
|
||||
|
@ -113,15 +107,16 @@ class PHPExcel_Calculation_Functions {
|
|||
* PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE 'OpenOfficeCalc'
|
||||
* @return boolean (Success or Failure)
|
||||
*/
|
||||
public static function setCompatibilityMode($compatibilityMode) {
|
||||
public static function setCompatibilityMode($compatibilityMode)
|
||||
{
|
||||
if (($compatibilityMode == self::COMPATIBILITY_EXCEL) ||
|
||||
($compatibilityMode == self::COMPATIBILITY_GNUMERIC) ||
|
||||
($compatibilityMode == self::COMPATIBILITY_OPENOFFICE)) {
|
||||
self::$compatibilityMode = $compatibilityMode;
|
||||
return True;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return False;
|
||||
} // function setCompatibilityMode()
|
||||
|
||||
|
||||
/**
|
||||
|
@ -135,9 +130,10 @@ class PHPExcel_Calculation_Functions {
|
|||
* PHPExcel_Calculation_Functions::COMPATIBILITY_GNUMERIC 'Gnumeric'
|
||||
* PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE 'OpenOfficeCalc'
|
||||
*/
|
||||
public static function getCompatibilityMode() {
|
||||
public static function getCompatibilityMode()
|
||||
{
|
||||
return self::$compatibilityMode;
|
||||
} // function getCompatibilityMode()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
@ -152,15 +148,16 @@ class PHPExcel_Calculation_Functions {
|
|||
* PHPExcel_Calculation_Functions::RETURNDATE_EXCEL 'E'
|
||||
* @return boolean Success or failure
|
||||
*/
|
||||
public static function setReturnDateType($returnDateType) {
|
||||
public static function setReturnDateType($returnDateType)
|
||||
{
|
||||
if (($returnDateType == self::RETURNDATE_PHP_NUMERIC) ||
|
||||
($returnDateType == self::RETURNDATE_PHP_OBJECT) ||
|
||||
($returnDateType == self::RETURNDATE_EXCEL)) {
|
||||
self::$ReturnDateType = $returnDateType;
|
||||
return True;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return False;
|
||||
} // function setReturnDateType()
|
||||
|
||||
|
||||
/**
|
||||
|
@ -174,9 +171,10 @@ class PHPExcel_Calculation_Functions {
|
|||
* PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT 'O'
|
||||
* PHPExcel_Calculation_Functions::RETURNDATE_EXCEL 'E'
|
||||
*/
|
||||
public static function getReturnDateType() {
|
||||
public static function getReturnDateType()
|
||||
{
|
||||
return self::$ReturnDateType;
|
||||
} // function getReturnDateType()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
@ -186,9 +184,10 @@ class PHPExcel_Calculation_Functions {
|
|||
* @category Error Returns
|
||||
* @return string #Not Yet Implemented
|
||||
*/
|
||||
public static function DUMMY() {
|
||||
public static function DUMMY()
|
||||
{
|
||||
return '#Not Yet Implemented';
|
||||
} // function DUMMY()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
@ -198,9 +197,10 @@ class PHPExcel_Calculation_Functions {
|
|||
* @category Error Returns
|
||||
* @return string #Not Yet Implemented
|
||||
*/
|
||||
public static function DIV0() {
|
||||
public static function DIV0()
|
||||
{
|
||||
return self::$_errorCodes['divisionbyzero'];
|
||||
} // function DIV0()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
@ -216,9 +216,10 @@ class PHPExcel_Calculation_Functions {
|
|||
* @category Logical Functions
|
||||
* @return string #N/A!
|
||||
*/
|
||||
public static function NA() {
|
||||
public static function NA()
|
||||
{
|
||||
return self::$_errorCodes['na'];
|
||||
} // function NA()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
@ -230,9 +231,10 @@ class PHPExcel_Calculation_Functions {
|
|||
* @category Error Returns
|
||||
* @return string #NUM!
|
||||
*/
|
||||
public static function NaN() {
|
||||
public static function NaN()
|
||||
{
|
||||
return self::$_errorCodes['num'];
|
||||
} // function NaN()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
@ -244,9 +246,10 @@ class PHPExcel_Calculation_Functions {
|
|||
* @category Error Returns
|
||||
* @return string #NAME?
|
||||
*/
|
||||
public static function NAME() {
|
||||
public static function NAME()
|
||||
{
|
||||
return self::$_errorCodes['name'];
|
||||
} // function NAME()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
@ -258,9 +261,10 @@ class PHPExcel_Calculation_Functions {
|
|||
* @category Error Returns
|
||||
* @return string #REF!
|
||||
*/
|
||||
public static function REF() {
|
||||
public static function REF()
|
||||
{
|
||||
return self::$_errorCodes['reference'];
|
||||
} // function REF()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
@ -272,9 +276,10 @@ class PHPExcel_Calculation_Functions {
|
|||
* @category Error Returns
|
||||
* @return string #NULL!
|
||||
*/
|
||||
public static function NULL() {
|
||||
public static function NULL()
|
||||
{
|
||||
return self::$_errorCodes['null'];
|
||||
} // function NULL()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
@ -286,32 +291,40 @@ class PHPExcel_Calculation_Functions {
|
|||
* @category Error Returns
|
||||
* @return string #VALUE!
|
||||
*/
|
||||
public static function VALUE() {
|
||||
public static function VALUE()
|
||||
{
|
||||
return self::$_errorCodes['value'];
|
||||
} // function VALUE()
|
||||
}
|
||||
|
||||
|
||||
public static function isMatrixValue($idx) {
|
||||
public static function isMatrixValue($idx)
|
||||
{
|
||||
return ((substr_count($idx, '.') <= 1) || (preg_match('/\.[A-Z]/', $idx) > 0));
|
||||
}
|
||||
|
||||
|
||||
public static function isValue($idx) {
|
||||
public static function isValue($idx)
|
||||
{
|
||||
return (substr_count($idx, '.') == 0);
|
||||
}
|
||||
|
||||
|
||||
public static function isCellValue($idx) {
|
||||
public static function isCellValue($idx)
|
||||
{
|
||||
return (substr_count($idx, '.') > 1);
|
||||
}
|
||||
|
||||
|
||||
public static function _ifCondition($condition) {
|
||||
public static function _ifCondition($condition)
|
||||
{
|
||||
$condition = PHPExcel_Calculation_Functions::flattenSingleValue($condition);
|
||||
if (!isset($condition{0}))
|
||||
if (!isset($condition{0})) {
|
||||
$condition = '=""';
|
||||
}
|
||||
if (!in_array($condition{0}, array('>', '<', '='))) {
|
||||
if (!is_numeric($condition)) { $condition = PHPExcel_Calculation::_wrapResult(strtoupper($condition)); }
|
||||
if (!is_numeric($condition)) {
|
||||
$condition = PHPExcel_Calculation::_wrapResult(strtoupper($condition));
|
||||
}
|
||||
return '=' . $condition;
|
||||
} else {
|
||||
preg_match('/([<>=]+)(.*)/', $condition, $matches);
|
||||
|
@ -324,8 +337,7 @@ class PHPExcel_Calculation_Functions {
|
|||
|
||||
return $operator.$operand;
|
||||
}
|
||||
} // function _ifCondition()
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* ERROR_TYPE
|
||||
|
@ -333,7 +345,8 @@ class PHPExcel_Calculation_Functions {
|
|||
* @param mixed $value Value to check
|
||||
* @return boolean
|
||||
*/
|
||||
public static function ERROR_TYPE($value = '') {
|
||||
public static function ERROR_TYPE($value = '')
|
||||
{
|
||||
$value = self::flattenSingleValue($value);
|
||||
|
||||
$i = 1;
|
||||
|
@ -344,7 +357,7 @@ class PHPExcel_Calculation_Functions {
|
|||
++$i;
|
||||
}
|
||||
return self::NA();
|
||||
} // function ERROR_TYPE()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
@ -353,13 +366,14 @@ class PHPExcel_Calculation_Functions {
|
|||
* @param mixed $value Value to check
|
||||
* @return boolean
|
||||
*/
|
||||
public static function IS_BLANK($value = NULL) {
|
||||
public static function IS_BLANK($value = null)
|
||||
{
|
||||
if (!is_null($value)) {
|
||||
$value = self::flattenSingleValue($value);
|
||||
}
|
||||
|
||||
return is_null($value);
|
||||
} // function IS_BLANK()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
@ -368,11 +382,12 @@ class PHPExcel_Calculation_Functions {
|
|||
* @param mixed $value Value to check
|
||||
* @return boolean
|
||||
*/
|
||||
public static function IS_ERR($value = '') {
|
||||
public static function IS_ERR($value = '')
|
||||
{
|
||||
$value = self::flattenSingleValue($value);
|
||||
|
||||
return self::IS_ERROR($value) && (!self::IS_NA($value));
|
||||
} // function IS_ERR()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
@ -381,13 +396,15 @@ class PHPExcel_Calculation_Functions {
|
|||
* @param mixed $value Value to check
|
||||
* @return boolean
|
||||
*/
|
||||
public static function IS_ERROR($value = '') {
|
||||
public static function IS_ERROR($value = '')
|
||||
{
|
||||
$value = self::flattenSingleValue($value);
|
||||
|
||||
if (!is_string($value))
|
||||
if (!is_string($value)) {
|
||||
return false;
|
||||
}
|
||||
return in_array($value, array_values(self::$_errorCodes));
|
||||
} // function IS_ERROR()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
@ -396,11 +413,12 @@ class PHPExcel_Calculation_Functions {
|
|||
* @param mixed $value Value to check
|
||||
* @return boolean
|
||||
*/
|
||||
public static function IS_NA($value = '') {
|
||||
public static function IS_NA($value = '')
|
||||
{
|
||||
$value = self::flattenSingleValue($value);
|
||||
|
||||
return ($value === self::NA());
|
||||
} // function IS_NA()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
@ -409,15 +427,18 @@ class PHPExcel_Calculation_Functions {
|
|||
* @param mixed $value Value to check
|
||||
* @return boolean
|
||||
*/
|
||||
public static function IS_EVEN($value = NULL) {
|
||||
public static function IS_EVEN($value = null)
|
||||
{
|
||||
$value = self::flattenSingleValue($value);
|
||||
|
||||
if ($value === NULL)
|
||||
if ($value === null) {
|
||||
return self::NAME();
|
||||
if ((is_bool($value)) || ((is_string($value)) && (!is_numeric($value))))
|
||||
} elseif ((is_bool($value)) || ((is_string($value)) && (!is_numeric($value)))) {
|
||||
return self::VALUE();
|
||||
}
|
||||
|
||||
return ($value % 2 == 0);
|
||||
} // function IS_EVEN()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
@ -426,15 +447,18 @@ class PHPExcel_Calculation_Functions {
|
|||
* @param mixed $value Value to check
|
||||
* @return boolean
|
||||
*/
|
||||
public static function IS_ODD($value = NULL) {
|
||||
public static function IS_ODD($value = null)
|
||||
{
|
||||
$value = self::flattenSingleValue($value);
|
||||
|
||||
if ($value === NULL)
|
||||
if ($value === null) {
|
||||
return self::NAME();
|
||||
if ((is_bool($value)) || ((is_string($value)) && (!is_numeric($value))))
|
||||
} elseif ((is_bool($value)) || ((is_string($value)) && (!is_numeric($value)))) {
|
||||
return self::VALUE();
|
||||
}
|
||||
|
||||
return (abs($value) % 2 == 1);
|
||||
} // function IS_ODD()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
@ -443,14 +467,15 @@ class PHPExcel_Calculation_Functions {
|
|||
* @param mixed $value Value to check
|
||||
* @return boolean
|
||||
*/
|
||||
public static function IS_NUMBER($value = NULL) {
|
||||
public static function IS_NUMBER($value = null)
|
||||
{
|
||||
$value = self::flattenSingleValue($value);
|
||||
|
||||
if (is_string($value)) {
|
||||
return False;
|
||||
return false;
|
||||
}
|
||||
return is_numeric($value);
|
||||
} // function IS_NUMBER()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
@ -459,11 +484,12 @@ class PHPExcel_Calculation_Functions {
|
|||
* @param mixed $value Value to check
|
||||
* @return boolean
|
||||
*/
|
||||
public static function IS_LOGICAL($value = NULL) {
|
||||
public static function IS_LOGICAL($value = null)
|
||||
{
|
||||
$value = self::flattenSingleValue($value);
|
||||
|
||||
return is_bool($value);
|
||||
} // function IS_LOGICAL()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
@ -472,11 +498,12 @@ class PHPExcel_Calculation_Functions {
|
|||
* @param mixed $value Value to check
|
||||
* @return boolean
|
||||
*/
|
||||
public static function IS_TEXT($value = NULL) {
|
||||
public static function IS_TEXT($value = null)
|
||||
{
|
||||
$value = self::flattenSingleValue($value);
|
||||
|
||||
return (is_string($value) && !self::IS_ERROR($value));
|
||||
} // function IS_TEXT()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
@ -485,9 +512,10 @@ class PHPExcel_Calculation_Functions {
|
|||
* @param mixed $value Value to check
|
||||
* @return boolean
|
||||
*/
|
||||
public static function IS_NONTEXT($value = NULL) {
|
||||
public static function IS_NONTEXT($value = null)
|
||||
{
|
||||
return !self::IS_TEXT($value);
|
||||
} // function IS_NONTEXT()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
@ -495,9 +523,10 @@ class PHPExcel_Calculation_Functions {
|
|||
*
|
||||
* @return string Version information
|
||||
*/
|
||||
public static function VERSION() {
|
||||
public static function VERSION()
|
||||
{
|
||||
return 'PHPExcel ##VERSION##, ##DATE##';
|
||||
} // function VERSION()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
@ -515,7 +544,8 @@ class PHPExcel_Calculation_Functions {
|
|||
* An error value The error value
|
||||
* Anything else 0
|
||||
*/
|
||||
public static function N($value = NULL) {
|
||||
public static function N($value = null)
|
||||
{
|
||||
while (is_array($value)) {
|
||||
$value = array_shift($value);
|
||||
}
|
||||
|
@ -537,7 +567,7 @@ class PHPExcel_Calculation_Functions {
|
|||
break;
|
||||
}
|
||||
return 0;
|
||||
} // function N()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
@ -554,11 +584,12 @@ class PHPExcel_Calculation_Functions {
|
|||
* An error value 16
|
||||
* Array or Matrix 64
|
||||
*/
|
||||
public static function TYPE($value = NULL) {
|
||||
public static function TYPE($value = null)
|
||||
{
|
||||
$value = self::flattenArrayIndexed($value);
|
||||
if (is_array($value) && (count($value) > 1)) {
|
||||
$a = array_keys($value);
|
||||
$a = array_pop($a);
|
||||
end($value);
|
||||
$a = key($value);
|
||||
// Range of cells is an error
|
||||
if (self::isCellValue($a)) {
|
||||
return 16;
|
||||
|
@ -572,7 +603,7 @@ class PHPExcel_Calculation_Functions {
|
|||
}
|
||||
$value = self::flattenSingleValue($value);
|
||||
|
||||
if (($value === NULL) || (is_float($value)) || (is_int($value))) {
|
||||
if (($value === null) || (is_float($value)) || (is_int($value))) {
|
||||
return 1;
|
||||
} elseif (is_bool($value)) {
|
||||
return 4;
|
||||
|
@ -586,7 +617,7 @@ class PHPExcel_Calculation_Functions {
|
|||
return 2;
|
||||
}
|
||||
return 0;
|
||||
} // function TYPE()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
@ -595,7 +626,8 @@ class PHPExcel_Calculation_Functions {
|
|||
* @param array $array Array to be flattened
|
||||
* @return array Flattened array
|
||||
*/
|
||||
public static function flattenArray($array) {
|
||||
public static function flattenArray($array)
|
||||
{
|
||||
if (!is_array($array)) {
|
||||
return (array) $array;
|
||||
}
|
||||
|
@ -618,7 +650,7 @@ class PHPExcel_Calculation_Functions {
|
|||
}
|
||||
|
||||
return $arrayValues;
|
||||
} // function flattenArray()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
@ -627,7 +659,8 @@ class PHPExcel_Calculation_Functions {
|
|||
* @param array $array Array to be flattened
|
||||
* @return array Flattened array
|
||||
*/
|
||||
public static function flattenArrayIndexed($array) {
|
||||
public static function flattenArrayIndexed($array)
|
||||
{
|
||||
if (!is_array($array)) {
|
||||
return (array) $array;
|
||||
}
|
||||
|
@ -650,7 +683,7 @@ class PHPExcel_Calculation_Functions {
|
|||
}
|
||||
|
||||
return $arrayValues;
|
||||
} // function flattenArrayIndexed()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
@ -659,15 +692,15 @@ class PHPExcel_Calculation_Functions {
|
|||
* @param mixed $value Array or scalar value
|
||||
* @return mixed
|
||||
*/
|
||||
public static function flattenSingleValue($value = '') {
|
||||
public static function flattenSingleValue($value = '')
|
||||
{
|
||||
while (is_array($value)) {
|
||||
$value = array_pop($value);
|
||||
}
|
||||
|
||||
return $value;
|
||||
} // function flattenSingleValue()
|
||||
|
||||
} // class PHPExcel_Calculation_Functions
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
|
@ -676,19 +709,22 @@ class PHPExcel_Calculation_Functions {
|
|||
// So we test if they do exist for this version of PHP/operating platform; and if not we create them
|
||||
//
|
||||
if (!function_exists('acosh')) {
|
||||
function acosh($x) {
|
||||
function acosh($x)
|
||||
{
|
||||
return 2 * log(sqrt(($x + 1) / 2) + sqrt(($x - 1) / 2));
|
||||
} // function acosh()
|
||||
}
|
||||
|
||||
if (!function_exists('asinh')) {
|
||||
function asinh($x) {
|
||||
function asinh($x)
|
||||
{
|
||||
return log($x + sqrt(1 + $x * $x));
|
||||
} // function asinh()
|
||||
}
|
||||
|
||||
if (!function_exists('atanh')) {
|
||||
function atanh($x) {
|
||||
function atanh($x)
|
||||
{
|
||||
return (log(1 + $x) - log(1 - $x)) / 2;
|
||||
} // function atanh()
|
||||
}
|
||||
|
@ -700,7 +736,8 @@ if (!function_exists('atanh')) {
|
|||
//
|
||||
if ((!function_exists('mb_str_replace')) &&
|
||||
(function_exists('mb_substr')) && (function_exists('mb_strlen')) && (function_exists('mb_strpos'))) {
|
||||
function mb_str_replace($search, $replace, $subject) {
|
||||
function mb_str_replace($search, $replace, $subject)
|
||||
{
|
||||
if (is_array($subject)) {
|
||||
$ret = array();
|
||||
foreach ($subject as $key => $val) {
|
||||
|
|
|
@ -1,6 +1,16 @@
|
|||
<?php
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* PHPExcel
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||
}
|
||||
|
||||
/**
|
||||
* PHPExcel_Calculation_Logical
|
||||
*
|
||||
* Copyright (c) 2006 - 2015 PHPExcel
|
||||
*
|
||||
|
@ -24,27 +34,8 @@
|
|||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Calculation_Logical
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Calculation
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Calculation_Logical {
|
||||
|
||||
class PHPExcel_Calculation_Logical
|
||||
{
|
||||
/**
|
||||
* TRUE
|
||||
*
|
||||
|
@ -57,9 +48,10 @@ class PHPExcel_Calculation_Logical {
|
|||
* @category Logical Functions
|
||||
* @return boolean True
|
||||
*/
|
||||
public static function TRUE() {
|
||||
return TRUE;
|
||||
} // function TRUE()
|
||||
public static function TRUE()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
@ -74,9 +66,10 @@ class PHPExcel_Calculation_Logical {
|
|||
* @category Logical Functions
|
||||
* @return boolean False
|
||||
*/
|
||||
public static function FALSE() {
|
||||
return FALSE;
|
||||
} // function FALSE()
|
||||
public static function FALSE()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
@ -100,9 +93,10 @@ class PHPExcel_Calculation_Logical {
|
|||
* @param mixed $arg,... Data values
|
||||
* @return boolean The logical AND of the arguments.
|
||||
*/
|
||||
public static function LOGICAL_AND() {
|
||||
public static function LOGICAL_AND()
|
||||
{
|
||||
// Return value
|
||||
$returnValue = TRUE;
|
||||
$returnValue = true;
|
||||
|
||||
// Loop through the arguments
|
||||
$aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
|
||||
|
@ -116,9 +110,9 @@ class PHPExcel_Calculation_Logical {
|
|||
} elseif (is_string($arg)) {
|
||||
$arg = strtoupper($arg);
|
||||
if (($arg == 'TRUE') || ($arg == PHPExcel_Calculation::getTRUE())) {
|
||||
$arg = TRUE;
|
||||
$arg = true;
|
||||
} elseif (($arg == 'FALSE') || ($arg == PHPExcel_Calculation::getFALSE())) {
|
||||
$arg = FALSE;
|
||||
$arg = false;
|
||||
} else {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
}
|
||||
|
@ -131,7 +125,7 @@ class PHPExcel_Calculation_Logical {
|
|||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
}
|
||||
return $returnValue;
|
||||
} // function LOGICAL_AND()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
@ -155,9 +149,10 @@ class PHPExcel_Calculation_Logical {
|
|||
* @param mixed $arg,... Data values
|
||||
* @return boolean The logical OR of the arguments.
|
||||
*/
|
||||
public static function LOGICAL_OR() {
|
||||
public static function LOGICAL_OR()
|
||||
{
|
||||
// Return value
|
||||
$returnValue = FALSE;
|
||||
$returnValue = false;
|
||||
|
||||
// Loop through the arguments
|
||||
$aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
|
||||
|
@ -171,9 +166,9 @@ class PHPExcel_Calculation_Logical {
|
|||
} elseif (is_string($arg)) {
|
||||
$arg = strtoupper($arg);
|
||||
if (($arg == 'TRUE') || ($arg == PHPExcel_Calculation::getTRUE())) {
|
||||
$arg = TRUE;
|
||||
$arg = true;
|
||||
} elseif (($arg == 'FALSE') || ($arg == PHPExcel_Calculation::getFALSE())) {
|
||||
$arg = FALSE;
|
||||
$arg = false;
|
||||
} else {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
}
|
||||
|
@ -186,7 +181,7 @@ class PHPExcel_Calculation_Logical {
|
|||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
}
|
||||
return $returnValue;
|
||||
} // function LOGICAL_OR()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
@ -209,21 +204,22 @@ class PHPExcel_Calculation_Logical {
|
|||
* @param mixed $logical A value or expression that can be evaluated to TRUE or FALSE
|
||||
* @return boolean The boolean inverse of the argument.
|
||||
*/
|
||||
public static function NOT($logical=FALSE) {
|
||||
public static function NOT($logical = false)
|
||||
{
|
||||
$logical = PHPExcel_Calculation_Functions::flattenSingleValue($logical);
|
||||
if (is_string($logical)) {
|
||||
$logical = strtoupper($logical);
|
||||
if (($logical == 'TRUE') || ($logical == PHPExcel_Calculation::getTRUE())) {
|
||||
return FALSE;
|
||||
return false;
|
||||
} elseif (($logical == 'FALSE') || ($logical == PHPExcel_Calculation::getFALSE())) {
|
||||
return TRUE;
|
||||
return true;
|
||||
} else {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
}
|
||||
}
|
||||
|
||||
return !$logical;
|
||||
} // function NOT()
|
||||
}
|
||||
|
||||
/**
|
||||
* STATEMENT_IF
|
||||
|
@ -257,13 +253,14 @@ class PHPExcel_Calculation_Logical {
|
|||
* @param mixed $returnIfFalse Optional value to return when condition is false
|
||||
* @return mixed The value of returnIfTrue or returnIfFalse determined by condition
|
||||
*/
|
||||
public static function STATEMENT_IF($condition = TRUE, $returnIfTrue = 0, $returnIfFalse = FALSE) {
|
||||
$condition = (is_null($condition)) ? TRUE : (boolean) PHPExcel_Calculation_Functions::flattenSingleValue($condition);
|
||||
public static function STATEMENT_IF($condition = true, $returnIfTrue = 0, $returnIfFalse = false)
|
||||
{
|
||||
$condition = (is_null($condition)) ? true : (boolean) PHPExcel_Calculation_Functions::flattenSingleValue($condition);
|
||||
$returnIfTrue = (is_null($returnIfTrue)) ? 0 : PHPExcel_Calculation_Functions::flattenSingleValue($returnIfTrue);
|
||||
$returnIfFalse = (is_null($returnIfFalse)) ? FALSE : PHPExcel_Calculation_Functions::flattenSingleValue($returnIfFalse);
|
||||
$returnIfFalse = (is_null($returnIfFalse)) ? false : PHPExcel_Calculation_Functions::flattenSingleValue($returnIfFalse);
|
||||
|
||||
return ($condition) ? $returnIfTrue : $returnIfFalse;
|
||||
} // function STATEMENT_IF()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
@ -278,11 +275,11 @@ class PHPExcel_Calculation_Logical {
|
|||
* @param mixed $errorpart Value to return when testValue is an error condition
|
||||
* @return mixed The value of errorpart or testValue determined by error condition
|
||||
*/
|
||||
public static function IFERROR($testValue = '', $errorpart = '') {
|
||||
public static function IFERROR($testValue = '', $errorpart = '')
|
||||
{
|
||||
$testValue = (is_null($testValue)) ? '' : PHPExcel_Calculation_Functions::flattenSingleValue($testValue);
|
||||
$errorpart = (is_null($errorpart)) ? '' : PHPExcel_Calculation_Functions::flattenSingleValue($errorpart);
|
||||
|
||||
return self::STATEMENT_IF(PHPExcel_Calculation_Functions::IS_ERROR($testValue), $errorpart, $testValue);
|
||||
} // function IFERROR()
|
||||
|
||||
} // class PHPExcel_Calculation_Logical
|
||||
}
|
||||
}
|
||||
|
|
|
@ -149,16 +149,15 @@ class PHPExcel_Calculation_LookupRef {
|
|||
* @param cellAddress An array or array formula, or a reference to a range of cells for which you want the number of columns
|
||||
* @return integer The number of columns in cellAddress
|
||||
*/
|
||||
public static function COLUMNS($cellAddress=Null) {
|
||||
public static function COLUMNS($cellAddress = null) {
|
||||
if (is_null($cellAddress) || $cellAddress === '') {
|
||||
return 1;
|
||||
} elseif (!is_array($cellAddress)) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
}
|
||||
|
||||
$x = array_keys($cellAddress);
|
||||
$x = array_shift($x);
|
||||
$isMatrix = (is_numeric($x));
|
||||
reset($cellAddress);
|
||||
$isMatrix = (is_numeric(key($cellAddress)));
|
||||
list($columns,$rows) = PHPExcel_Calculation::_getMatrixDimensions($cellAddress);
|
||||
|
||||
if ($isMatrix) {
|
||||
|
@ -231,8 +230,8 @@ class PHPExcel_Calculation_LookupRef {
|
|||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
}
|
||||
|
||||
$i = array_keys($cellAddress);
|
||||
$isMatrix = (is_numeric(array_shift($i)));
|
||||
reset($cellAddress);
|
||||
$isMatrix = (is_numeric(key($cellAddress)));
|
||||
list($columns,$rows) = PHPExcel_Calculation::_getMatrixDimensions($cellAddress);
|
||||
|
||||
if ($isMatrix) {
|
||||
|
@ -672,8 +671,8 @@ class PHPExcel_Calculation_LookupRef {
|
|||
|
||||
|
||||
private static function _vlookupSort($a,$b) {
|
||||
$f = array_keys($a);
|
||||
$firstColumn = array_shift($f);
|
||||
reset($a);
|
||||
$firstColumn = key($a);
|
||||
if (strtolower($a[$firstColumn]) == strtolower($b[$firstColumn])) {
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -2526,7 +2526,7 @@ class PHPExcel_Calculation_Statistical {
|
|||
}
|
||||
if ((is_numeric($cumulative)) || (is_bool($cumulative))) {
|
||||
if ($cumulative) {
|
||||
return 0.5 * (1 + PHPExcel_Calculation_Engineering::_erfVal(($value - $mean) / ($stdDev * sqrt(2))));
|
||||
return 0.5 * (1 + PHPExcel_Calculation_Engineering::erfVal(($value - $mean) / ($stdDev * sqrt(2))));
|
||||
} else {
|
||||
return (1 / (SQRT2PI * $stdDev)) * exp(0 - (pow($value - $mean,2) / (2 * ($stdDev * $stdDev))));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue