More PSR-2 modifications
This commit is contained in:
parent
b8f67c6f4d
commit
c07b54172a
|
@ -1,6 +1,16 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/** PHPExcel root directory */
|
||||||
|
if (!defined('PHPEXCEL_ROOT')) {
|
||||||
|
/**
|
||||||
|
* @ignore
|
||||||
|
*/
|
||||||
|
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||||
|
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel_Calculation_DateTime
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2015 PHPExcel
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
*
|
*
|
||||||
|
@ -24,25 +34,6 @@
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @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
|
class PHPExcel_Calculation_DateTime
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -95,12 +86,12 @@ class PHPExcel_Calculation_DateTime
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* _getDateValue
|
* getDateValue
|
||||||
*
|
*
|
||||||
* @param string $dateValue
|
* @param string $dateValue
|
||||||
* @return mixed Excel date/time serial value, or string if error
|
* @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_numeric($dateValue)) {
|
||||||
if ((is_string($dateValue)) &&
|
if ((is_string($dateValue)) &&
|
||||||
|
@ -121,12 +112,12 @@ class PHPExcel_Calculation_DateTime
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* _getTimeValue
|
* getTimeValue
|
||||||
*
|
*
|
||||||
* @param string $timeValue
|
* @param string $timeValue
|
||||||
* @return mixed Excel date/time serial value, or string if error
|
* @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();
|
$saveReturnDateType = PHPExcel_Calculation_Functions::getReturnDateType();
|
||||||
PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL);
|
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
|
// Execute function
|
||||||
$PHPDateObject = PHPExcel_Shared_Date::ExcelToPHPObject($dateValue);
|
$PHPDateObject = PHPExcel_Shared_Date::ExcelToPHPObject($dateValue);
|
||||||
|
@ -669,10 +660,10 @@ class PHPExcel_Calculation_DateTime
|
||||||
$endDate = PHPExcel_Calculation_Functions::flattenSingleValue($endDate);
|
$endDate = PHPExcel_Calculation_Functions::flattenSingleValue($endDate);
|
||||||
$unit = strtoupper(PHPExcel_Calculation_Functions::flattenSingleValue($unit));
|
$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();
|
return PHPExcel_Calculation_Functions::VALUE();
|
||||||
}
|
}
|
||||||
if (is_string($endDate = self::_getDateValue($endDate))) {
|
if (is_string($endDate = self::getDateValue($endDate))) {
|
||||||
return PHPExcel_Calculation_Functions::VALUE();
|
return PHPExcel_Calculation_Functions::VALUE();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -791,10 +782,10 @@ class PHPExcel_Calculation_DateTime
|
||||||
$startDate = PHPExcel_Calculation_Functions::flattenSingleValue($startDate);
|
$startDate = PHPExcel_Calculation_Functions::flattenSingleValue($startDate);
|
||||||
$endDate = PHPExcel_Calculation_Functions::flattenSingleValue($endDate);
|
$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();
|
return PHPExcel_Calculation_Functions::VALUE();
|
||||||
}
|
}
|
||||||
if (is_string($endDate = self::_getDateValue($endDate))) {
|
if (is_string($endDate = self::getDateValue($endDate))) {
|
||||||
return PHPExcel_Calculation_Functions::VALUE();
|
return PHPExcel_Calculation_Functions::VALUE();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -848,10 +839,10 @@ class PHPExcel_Calculation_DateTime
|
||||||
$endDate = PHPExcel_Calculation_Functions::flattenSingleValue($endDate);
|
$endDate = PHPExcel_Calculation_Functions::flattenSingleValue($endDate);
|
||||||
$method = PHPExcel_Calculation_Functions::flattenSingleValue($method);
|
$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();
|
return PHPExcel_Calculation_Functions::VALUE();
|
||||||
}
|
}
|
||||||
if (is_string($endDate = self::_getDateValue($endDate))) {
|
if (is_string($endDate = self::getDateValue($endDate))) {
|
||||||
return PHPExcel_Calculation_Functions::VALUE();
|
return PHPExcel_Calculation_Functions::VALUE();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -949,11 +940,11 @@ class PHPExcel_Calculation_DateTime
|
||||||
array_shift($dateArgs);
|
array_shift($dateArgs);
|
||||||
|
|
||||||
// Validate the start and end dates
|
// 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();
|
return PHPExcel_Calculation_Functions::VALUE();
|
||||||
}
|
}
|
||||||
$startDate = (float) floor($startDate);
|
$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();
|
return PHPExcel_Calculation_Functions::VALUE();
|
||||||
}
|
}
|
||||||
$endDate = (float) floor($endDate);
|
$endDate = (float) floor($endDate);
|
||||||
|
@ -982,7 +973,7 @@ class PHPExcel_Calculation_DateTime
|
||||||
// Test any extra holiday parameters
|
// Test any extra holiday parameters
|
||||||
$holidayCountedArray = array();
|
$holidayCountedArray = array();
|
||||||
foreach ($dateArgs as $holidayDate) {
|
foreach ($dateArgs as $holidayDate) {
|
||||||
if (is_string($holidayDate = self::_getDateValue($holidayDate))) {
|
if (is_string($holidayDate = self::getDateValue($holidayDate))) {
|
||||||
return PHPExcel_Calculation_Functions::VALUE();
|
return PHPExcel_Calculation_Functions::VALUE();
|
||||||
}
|
}
|
||||||
if (($holidayDate >= $startDate) && ($holidayDate <= $endDate)) {
|
if (($holidayDate >= $startDate) && ($holidayDate <= $endDate)) {
|
||||||
|
@ -1035,7 +1026,7 @@ class PHPExcel_Calculation_DateTime
|
||||||
array_shift($dateArgs);
|
array_shift($dateArgs);
|
||||||
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();
|
return PHPExcel_Calculation_Functions::VALUE();
|
||||||
}
|
}
|
||||||
$startDate = (float) floor($startDate);
|
$startDate = (float) floor($startDate);
|
||||||
|
@ -1069,7 +1060,7 @@ class PHPExcel_Calculation_DateTime
|
||||||
$holidayCountedArray = $holidayDates = array();
|
$holidayCountedArray = $holidayDates = array();
|
||||||
foreach ($dateArgs as $holidayDate) {
|
foreach ($dateArgs as $holidayDate) {
|
||||||
if (($holidayDate !== null) && (trim($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();
|
return PHPExcel_Calculation_Functions::VALUE();
|
||||||
}
|
}
|
||||||
if (self::DAYOFWEEK($holidayDate, 3) < 5) {
|
if (self::DAYOFWEEK($holidayDate, 3) < 5) {
|
||||||
|
@ -1136,7 +1127,7 @@ class PHPExcel_Calculation_DateTime
|
||||||
|
|
||||||
if ($dateValue === null) {
|
if ($dateValue === null) {
|
||||||
$dateValue = 1;
|
$dateValue = 1;
|
||||||
} elseif (is_string($dateValue = self::_getDateValue($dateValue))) {
|
} elseif (is_string($dateValue = self::getDateValue($dateValue))) {
|
||||||
return PHPExcel_Calculation_Functions::VALUE();
|
return PHPExcel_Calculation_Functions::VALUE();
|
||||||
} elseif ($dateValue == 0.0) {
|
} elseif ($dateValue == 0.0) {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1182,7 +1173,7 @@ class PHPExcel_Calculation_DateTime
|
||||||
|
|
||||||
if ($dateValue === null) {
|
if ($dateValue === null) {
|
||||||
$dateValue = 1;
|
$dateValue = 1;
|
||||||
} elseif (is_string($dateValue = self::_getDateValue($dateValue))) {
|
} elseif (is_string($dateValue = self::getDateValue($dateValue))) {
|
||||||
return PHPExcel_Calculation_Functions::VALUE();
|
return PHPExcel_Calculation_Functions::VALUE();
|
||||||
} elseif ($dateValue < 0.0) {
|
} elseif ($dateValue < 0.0) {
|
||||||
return PHPExcel_Calculation_Functions::NaN();
|
return PHPExcel_Calculation_Functions::NaN();
|
||||||
|
@ -1258,7 +1249,7 @@ class PHPExcel_Calculation_DateTime
|
||||||
|
|
||||||
if ($dateValue === null) {
|
if ($dateValue === null) {
|
||||||
$dateValue = 1;
|
$dateValue = 1;
|
||||||
} elseif (is_string($dateValue = self::_getDateValue($dateValue))) {
|
} elseif (is_string($dateValue = self::getDateValue($dateValue))) {
|
||||||
return PHPExcel_Calculation_Functions::VALUE();
|
return PHPExcel_Calculation_Functions::VALUE();
|
||||||
} elseif ($dateValue < 0.0) {
|
} elseif ($dateValue < 0.0) {
|
||||||
return PHPExcel_Calculation_Functions::NaN();
|
return PHPExcel_Calculation_Functions::NaN();
|
||||||
|
@ -1297,7 +1288,7 @@ class PHPExcel_Calculation_DateTime
|
||||||
|
|
||||||
if ($dateValue === null) {
|
if ($dateValue === null) {
|
||||||
$dateValue = 1;
|
$dateValue = 1;
|
||||||
} elseif (is_string($dateValue = self::_getDateValue($dateValue))) {
|
} elseif (is_string($dateValue = self::getDateValue($dateValue))) {
|
||||||
return PHPExcel_Calculation_Functions::VALUE();
|
return PHPExcel_Calculation_Functions::VALUE();
|
||||||
} elseif ($dateValue < 0.0) {
|
} elseif ($dateValue < 0.0) {
|
||||||
return PHPExcel_Calculation_Functions::NaN();
|
return PHPExcel_Calculation_Functions::NaN();
|
||||||
|
@ -1329,7 +1320,7 @@ class PHPExcel_Calculation_DateTime
|
||||||
|
|
||||||
if ($dateValue === null) {
|
if ($dateValue === null) {
|
||||||
$dateValue = 1;
|
$dateValue = 1;
|
||||||
} elseif (is_string($dateValue = self::_getDateValue($dateValue))) {
|
} elseif (is_string($dateValue = self::getDateValue($dateValue))) {
|
||||||
return PHPExcel_Calculation_Functions::VALUE();
|
return PHPExcel_Calculation_Functions::VALUE();
|
||||||
} elseif ($dateValue < 0.0) {
|
} elseif ($dateValue < 0.0) {
|
||||||
return PHPExcel_Calculation_Functions::NaN();
|
return PHPExcel_Calculation_Functions::NaN();
|
||||||
|
@ -1366,7 +1357,7 @@ class PHPExcel_Calculation_DateTime
|
||||||
return PHPExcel_Calculation_Functions::VALUE();
|
return PHPExcel_Calculation_Functions::VALUE();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$timeValue = self::_getTimeValue($timeValue);
|
$timeValue = self::getTimeValue($timeValue);
|
||||||
if (is_string($timeValue)) {
|
if (is_string($timeValue)) {
|
||||||
return PHPExcel_Calculation_Functions::VALUE();
|
return PHPExcel_Calculation_Functions::VALUE();
|
||||||
}
|
}
|
||||||
|
@ -1407,7 +1398,7 @@ class PHPExcel_Calculation_DateTime
|
||||||
return PHPExcel_Calculation_Functions::VALUE();
|
return PHPExcel_Calculation_Functions::VALUE();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$timeValue = self::_getTimeValue($timeValue);
|
$timeValue = self::getTimeValue($timeValue);
|
||||||
if (is_string($timeValue)) {
|
if (is_string($timeValue)) {
|
||||||
return PHPExcel_Calculation_Functions::VALUE();
|
return PHPExcel_Calculation_Functions::VALUE();
|
||||||
}
|
}
|
||||||
|
@ -1448,7 +1439,7 @@ class PHPExcel_Calculation_DateTime
|
||||||
return PHPExcel_Calculation_Functions::VALUE();
|
return PHPExcel_Calculation_Functions::VALUE();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$timeValue = self::_getTimeValue($timeValue);
|
$timeValue = self::getTimeValue($timeValue);
|
||||||
if (is_string($timeValue)) {
|
if (is_string($timeValue)) {
|
||||||
return PHPExcel_Calculation_Functions::VALUE();
|
return PHPExcel_Calculation_Functions::VALUE();
|
||||||
}
|
}
|
||||||
|
@ -1494,12 +1485,12 @@ class PHPExcel_Calculation_DateTime
|
||||||
}
|
}
|
||||||
$adjustmentMonths = floor($adjustmentMonths);
|
$adjustmentMonths = floor($adjustmentMonths);
|
||||||
|
|
||||||
if (is_string($dateValue = self::_getDateValue($dateValue))) {
|
if (is_string($dateValue = self::getDateValue($dateValue))) {
|
||||||
return PHPExcel_Calculation_Functions::VALUE();
|
return PHPExcel_Calculation_Functions::VALUE();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Execute function
|
// Execute function
|
||||||
$PHPDateObject = self::_adjustDateByMonths($dateValue, $adjustmentMonths);
|
$PHPDateObject = self::adjustDateByMonths($dateValue, $adjustmentMonths);
|
||||||
|
|
||||||
switch (PHPExcel_Calculation_Functions::getReturnDateType()) {
|
switch (PHPExcel_Calculation_Functions::getReturnDateType()) {
|
||||||
case PHPExcel_Calculation_Functions::RETURNDATE_EXCEL:
|
case PHPExcel_Calculation_Functions::RETURNDATE_EXCEL:
|
||||||
|
@ -1540,12 +1531,12 @@ class PHPExcel_Calculation_DateTime
|
||||||
}
|
}
|
||||||
$adjustmentMonths = floor($adjustmentMonths);
|
$adjustmentMonths = floor($adjustmentMonths);
|
||||||
|
|
||||||
if (is_string($dateValue = self::_getDateValue($dateValue))) {
|
if (is_string($dateValue = self::getDateValue($dateValue))) {
|
||||||
return PHPExcel_Calculation_Functions::VALUE();
|
return PHPExcel_Calculation_Functions::VALUE();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Execute function
|
// Execute function
|
||||||
$PHPDateObject = self::_adjustDateByMonths($dateValue, $adjustmentMonths+1);
|
$PHPDateObject = self::adjustDateByMonths($dateValue, $adjustmentMonths+1);
|
||||||
$adjustDays = (int) $PHPDateObject->format('d');
|
$adjustDays = (int) $PHPDateObject->format('d');
|
||||||
$adjustDaysString = '-' . $adjustDays . ' days';
|
$adjustDaysString = '-' . $adjustDays . ' days';
|
||||||
$PHPDateObject->modify($adjustDaysString);
|
$PHPDateObject->modify($adjustDaysString);
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,6 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel_Calculation_Exception
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2015 PHPExcel
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
*
|
*
|
||||||
|
@ -24,16 +25,8 @@
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
class PHPExcel_Calculation_Exception extends PHPExcel_Exception
|
||||||
|
{
|
||||||
/**
|
|
||||||
* 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 {
|
|
||||||
/**
|
/**
|
||||||
* Error handler callback
|
* Error handler callback
|
||||||
*
|
*
|
||||||
|
@ -43,7 +36,8 @@ class PHPExcel_Calculation_Exception extends PHPExcel_Exception {
|
||||||
* @param mixed $line
|
* @param mixed $line
|
||||||
* @param mixed $context
|
* @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 = new self($string, $code);
|
||||||
$e->line = $line;
|
$e->line = $line;
|
||||||
$e->file = $file;
|
$e->file = $file;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel_Calculation_ExceptionHandler
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2015 PHPExcel
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
*
|
*
|
||||||
|
@ -24,26 +25,21 @@
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
class PHPExcel_Calculation_ExceptionHandler
|
||||||
/**
|
{
|
||||||
* PHPExcel_Calculation_ExceptionHandler
|
|
||||||
*
|
|
||||||
* @category PHPExcel
|
|
||||||
* @package PHPExcel_Calculation
|
|
||||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
|
||||||
*/
|
|
||||||
class PHPExcel_Calculation_ExceptionHandler {
|
|
||||||
/**
|
/**
|
||||||
* Register errorhandler
|
* Register errorhandler
|
||||||
*/
|
*/
|
||||||
public function __construct() {
|
public function __construct()
|
||||||
|
{
|
||||||
set_error_handler(array('PHPExcel_Calculation_Exception', 'errorHandlerCallback'), E_ALL);
|
set_error_handler(array('PHPExcel_Calculation_Exception', 'errorHandlerCallback'), E_ALL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unregister errorhandler
|
* Unregister errorhandler
|
||||||
*/
|
*/
|
||||||
public function __destruct() {
|
public function __destruct()
|
||||||
|
{
|
||||||
restore_error_handler();
|
restore_error_handler();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,30 +1,4 @@
|
||||||
<?php
|
<?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:
|
PARTLY BASED ON:
|
||||||
|
@ -52,11 +26,32 @@ PARTLY BASED ON:
|
||||||
/**
|
/**
|
||||||
* PHPExcel_Calculation_FormulaParser
|
* 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
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Calculation
|
* @package PHPExcel_Calculation
|
||||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @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 */
|
/* Character constants */
|
||||||
const QUOTE_DOUBLE = '"';
|
const QUOTE_DOUBLE = '"';
|
||||||
const QUOTE_SINGLE = '\'';
|
const QUOTE_SINGLE = '\'';
|
||||||
|
@ -80,14 +75,14 @@ class PHPExcel_Calculation_FormulaParser {
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_formula;
|
private $formula;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tokens
|
* Tokens
|
||||||
*
|
*
|
||||||
* @var PHPExcel_Calculation_FormulaToken[]
|
* @var PHPExcel_Calculation_FormulaToken[]
|
||||||
*/
|
*/
|
||||||
private $_tokens = array();
|
private $tokens = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new PHPExcel_Calculation_FormulaParser
|
* Create a new PHPExcel_Calculation_FormulaParser
|
||||||
|
@ -103,9 +98,9 @@ class PHPExcel_Calculation_FormulaParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialise values
|
// Initialise values
|
||||||
$this->_formula = trim($pFormula);
|
$this->formula = trim($pFormula);
|
||||||
// Parse!
|
// Parse!
|
||||||
$this->_parseToTokens();
|
$this->parseToTokens();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -113,8 +108,9 @@ class PHPExcel_Calculation_FormulaParser {
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getFormula() {
|
public function getFormula()
|
||||||
return $this->_formula;
|
{
|
||||||
|
return $this->formula;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -124,9 +120,10 @@ class PHPExcel_Calculation_FormulaParser {
|
||||||
* @return string
|
* @return string
|
||||||
* @throws PHPExcel_Calculation_Exception
|
* @throws PHPExcel_Calculation_Exception
|
||||||
*/
|
*/
|
||||||
public function getToken($pId = 0) {
|
public function getToken($pId = 0)
|
||||||
if (isset($this->_tokens[$pId])) {
|
{
|
||||||
return $this->_tokens[$pId];
|
if (isset($this->tokens[$pId])) {
|
||||||
|
return $this->tokens[$pId];
|
||||||
} else {
|
} else {
|
||||||
throw new PHPExcel_Calculation_Exception("Token with id $pId does not exist.");
|
throw new PHPExcel_Calculation_Exception("Token with id $pId does not exist.");
|
||||||
}
|
}
|
||||||
|
@ -137,8 +134,9 @@ class PHPExcel_Calculation_FormulaParser {
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getTokenCount() {
|
public function getTokenCount()
|
||||||
return count($this->_tokens);
|
{
|
||||||
|
return count($this->tokens);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -146,20 +144,24 @@ class PHPExcel_Calculation_FormulaParser {
|
||||||
*
|
*
|
||||||
* @return PHPExcel_Calculation_FormulaToken[]
|
* @return PHPExcel_Calculation_FormulaToken[]
|
||||||
*/
|
*/
|
||||||
public function getTokens() {
|
public function getTokens()
|
||||||
return $this->_tokens;
|
{
|
||||||
|
return $this->tokens;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse to tokens
|
* Parse to tokens
|
||||||
*/
|
*/
|
||||||
private function _parseToTokens() {
|
private function parseToTokens()
|
||||||
|
{
|
||||||
// No attempt is made to verify formulas; assumes formulas are derived from Excel, where
|
// 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.
|
// they can only exist if valid; stack overflows/underflows sunk as nulls without exceptions.
|
||||||
|
|
||||||
// Check if the formula has a valid starting =
|
// Check if the formula has a valid starting =
|
||||||
$formulaLength = strlen($this->_formula);
|
$formulaLength = strlen($this->formula);
|
||||||
if ($formulaLength < 2 || $this->_formula{0} != '=') return;
|
if ($formulaLength < 2 || $this->formula{0} != '=') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Helper variables
|
// Helper variables
|
||||||
$tokens1 = $tokens2 = $stack = array();
|
$tokens1 = $tokens2 = $stack = array();
|
||||||
|
@ -179,8 +181,8 @@ class PHPExcel_Calculation_FormulaParser {
|
||||||
// embeds are doubled
|
// embeds are doubled
|
||||||
// end marks token
|
// end marks token
|
||||||
if ($inString) {
|
if ($inString) {
|
||||||
if ($this->_formula{$index} == 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)) {
|
if ((($index + 2) <= $formulaLength) && ($this->formula{$index + 1} == PHPExcel_Calculation_FormulaParser::QUOTE_DOUBLE)) {
|
||||||
$value .= PHPExcel_Calculation_FormulaParser::QUOTE_DOUBLE;
|
$value .= PHPExcel_Calculation_FormulaParser::QUOTE_DOUBLE;
|
||||||
++$index;
|
++$index;
|
||||||
} else {
|
} else {
|
||||||
|
@ -189,7 +191,7 @@ class PHPExcel_Calculation_FormulaParser {
|
||||||
$value = "";
|
$value = "";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$value .= $this->_formula{$index};
|
$value .= $this->formula{$index};
|
||||||
}
|
}
|
||||||
++$index;
|
++$index;
|
||||||
continue;
|
continue;
|
||||||
|
@ -199,15 +201,15 @@ class PHPExcel_Calculation_FormulaParser {
|
||||||
// embeds are double
|
// embeds are double
|
||||||
// end does not mark a token
|
// end does not mark a token
|
||||||
if ($inPath) {
|
if ($inPath) {
|
||||||
if ($this->_formula{$index} == 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)) {
|
if ((($index + 2) <= $formulaLength) && ($this->formula{$index + 1} == PHPExcel_Calculation_FormulaParser::QUOTE_SINGLE)) {
|
||||||
$value .= PHPExcel_Calculation_FormulaParser::QUOTE_SINGLE;
|
$value .= PHPExcel_Calculation_FormulaParser::QUOTE_SINGLE;
|
||||||
++$index;
|
++$index;
|
||||||
} else {
|
} else {
|
||||||
$inPath = false;
|
$inPath = false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$value .= $this->_formula{$index};
|
$value .= $this->formula{$index};
|
||||||
}
|
}
|
||||||
++$index;
|
++$index;
|
||||||
continue;
|
continue;
|
||||||
|
@ -217,10 +219,10 @@ class PHPExcel_Calculation_FormulaParser {
|
||||||
// no embeds (changed to "()" by Excel)
|
// no embeds (changed to "()" by Excel)
|
||||||
// end does not mark a token
|
// end does not mark a token
|
||||||
if ($inRange) {
|
if ($inRange) {
|
||||||
if ($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::BRACKET_CLOSE) {
|
if ($this->formula{$index} == PHPExcel_Calculation_FormulaParser::BRACKET_CLOSE) {
|
||||||
$inRange = false;
|
$inRange = false;
|
||||||
}
|
}
|
||||||
$value .= $this->_formula{$index};
|
$value .= $this->formula{$index};
|
||||||
++$index;
|
++$index;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -228,7 +230,7 @@ class PHPExcel_Calculation_FormulaParser {
|
||||||
// error values
|
// error values
|
||||||
// end marks a token, determined from absolute list of values
|
// end marks a token, determined from absolute list of values
|
||||||
if ($inError) {
|
if ($inError) {
|
||||||
$value .= $this->_formula{$index};
|
$value .= $this->formula{$index};
|
||||||
++$index;
|
++$index;
|
||||||
if (in_array($value, $ERRORS)) {
|
if (in_array($value, $ERRORS)) {
|
||||||
$inError = false;
|
$inError = false;
|
||||||
|
@ -239,10 +241,10 @@ class PHPExcel_Calculation_FormulaParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
// scientific notation check
|
// 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 (strlen($value) > 1) {
|
||||||
if (preg_match("/^[1-9]{1}(\.[0-9]+)?E{1}$/", $this->_formula{$index}) != 0) {
|
if (preg_match("/^[1-9]{1}(\.[0-9]+)?E{1}$/", $this->formula{$index}) != 0) {
|
||||||
$value .= $this->_formula{$index};
|
$value .= $this->formula{$index};
|
||||||
++$index;
|
++$index;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -252,18 +254,20 @@ class PHPExcel_Calculation_FormulaParser {
|
||||||
// independent character evaluation (order not important)
|
// independent character evaluation (order not important)
|
||||||
|
|
||||||
// establish state-dependent character evaluations
|
// establish state-dependent character evaluations
|
||||||
if ($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::QUOTE_DOUBLE) {
|
if ($this->formula{$index} == PHPExcel_Calculation_FormulaParser::QUOTE_DOUBLE) {
|
||||||
if (strlen($value > 0)) { // unexpected
|
if (strlen($value > 0)) {
|
||||||
|
// unexpected
|
||||||
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_UNKNOWN);
|
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_UNKNOWN);
|
||||||
$value = "";
|
$value = "";
|
||||||
}
|
}
|
||||||
$inString = true;
|
$inString = true;
|
||||||
++$index;
|
++$index;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::QUOTE_SINGLE) {
|
if ($this->formula{$index} == PHPExcel_Calculation_FormulaParser::QUOTE_SINGLE) {
|
||||||
if (strlen($value) > 0) { // unexpected
|
if (strlen($value) > 0) {
|
||||||
|
// unexpected
|
||||||
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_UNKNOWN);
|
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_UNKNOWN);
|
||||||
$value = "";
|
$value = "";
|
||||||
}
|
}
|
||||||
|
@ -272,15 +276,16 @@ class PHPExcel_Calculation_FormulaParser {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::BRACKET_OPEN) {
|
if ($this->formula{$index} == PHPExcel_Calculation_FormulaParser::BRACKET_OPEN) {
|
||||||
$inRange = true;
|
$inRange = true;
|
||||||
$value .= PHPExcel_Calculation_FormulaParser::BRACKET_OPEN;
|
$value .= PHPExcel_Calculation_FormulaParser::BRACKET_OPEN;
|
||||||
++$index;
|
++$index;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::ERROR_START) {
|
if ($this->formula{$index} == PHPExcel_Calculation_FormulaParser::ERROR_START) {
|
||||||
if (strlen($value) > 0) { // unexpected
|
if (strlen($value) > 0) {
|
||||||
|
// unexpected
|
||||||
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_UNKNOWN);
|
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_UNKNOWN);
|
||||||
$value = "";
|
$value = "";
|
||||||
}
|
}
|
||||||
|
@ -291,8 +296,9 @@ class PHPExcel_Calculation_FormulaParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
// mark start and end of arrays and array rows
|
// mark start and end of arrays and array rows
|
||||||
if ($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::BRACE_OPEN) {
|
if ($this->formula{$index} == PHPExcel_Calculation_FormulaParser::BRACE_OPEN) {
|
||||||
if (strlen($value) > 0) { // unexpected
|
if (strlen($value) > 0) {
|
||||||
|
// unexpected
|
||||||
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_UNKNOWN);
|
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_UNKNOWN);
|
||||||
$value = "";
|
$value = "";
|
||||||
}
|
}
|
||||||
|
@ -309,7 +315,7 @@ class PHPExcel_Calculation_FormulaParser {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::SEMICOLON) {
|
if ($this->formula{$index} == PHPExcel_Calculation_FormulaParser::SEMICOLON) {
|
||||||
if (strlen($value) > 0) {
|
if (strlen($value) > 0) {
|
||||||
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
|
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
|
||||||
$value = "";
|
$value = "";
|
||||||
|
@ -331,7 +337,7 @@ class PHPExcel_Calculation_FormulaParser {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::BRACE_CLOSE) {
|
if ($this->formula{$index} == PHPExcel_Calculation_FormulaParser::BRACE_CLOSE) {
|
||||||
if (strlen($value) > 0) {
|
if (strlen($value) > 0) {
|
||||||
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
|
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
|
||||||
$value = "";
|
$value = "";
|
||||||
|
@ -352,14 +358,14 @@ class PHPExcel_Calculation_FormulaParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
// trim white-space
|
// trim white-space
|
||||||
if ($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::WHITESPACE) {
|
if ($this->formula{$index} == PHPExcel_Calculation_FormulaParser::WHITESPACE) {
|
||||||
if (strlen($value) > 0) {
|
if (strlen($value) > 0) {
|
||||||
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
|
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
|
||||||
$value = "";
|
$value = "";
|
||||||
}
|
}
|
||||||
$tokens1[] = new PHPExcel_Calculation_FormulaToken("", PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_WHITESPACE);
|
$tokens1[] = new PHPExcel_Calculation_FormulaToken("", PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_WHITESPACE);
|
||||||
++$index;
|
++$index;
|
||||||
while (($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::WHITESPACE) && ($index < $formulaLength)) {
|
while (($this->formula{$index} == PHPExcel_Calculation_FormulaParser::WHITESPACE) && ($index < $formulaLength)) {
|
||||||
++$index;
|
++$index;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
@ -367,41 +373,41 @@ class PHPExcel_Calculation_FormulaParser {
|
||||||
|
|
||||||
// multi-character comparators
|
// multi-character comparators
|
||||||
if (($index + 2) <= $formulaLength) {
|
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) {
|
if (strlen($value) > 0) {
|
||||||
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
|
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
|
||||||
$value = "";
|
$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;
|
$index += 2;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// standard infix operators
|
// 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) {
|
if (strlen($value) > 0) {
|
||||||
$tokens1[] =new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
|
$tokens1[] =new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
|
||||||
$value = "";
|
$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;
|
++$index;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// standard postfix operators (only one)
|
// 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) {
|
if (strlen($value) > 0) {
|
||||||
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
|
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
|
||||||
$value = "";
|
$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;
|
++$index;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// start subexpression or function
|
// 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) {
|
if (strlen($value) > 0) {
|
||||||
$tmp = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_FUNCTION, PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_START);
|
$tmp = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_FUNCTION, PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_START);
|
||||||
$tokens1[] = $tmp;
|
$tokens1[] = $tmp;
|
||||||
|
@ -417,7 +423,7 @@ class PHPExcel_Calculation_FormulaParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
// function, subexpression, or array parameters, or operand unions
|
// 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) {
|
if (strlen($value) > 0) {
|
||||||
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
|
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
|
||||||
$value = "";
|
$value = "";
|
||||||
|
@ -438,7 +444,7 @@ class PHPExcel_Calculation_FormulaParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
// stop subexpression
|
// stop subexpression
|
||||||
if ($this->_formula{$index} == PHPExcel_Calculation_FormulaParser::PAREN_CLOSE) {
|
if ($this->formula{$index} == PHPExcel_Calculation_FormulaParser::PAREN_CLOSE) {
|
||||||
if (strlen($value) > 0) {
|
if (strlen($value) > 0) {
|
||||||
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
|
$tokens1[] = new PHPExcel_Calculation_FormulaToken($value, PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND);
|
||||||
$value = "";
|
$value = "";
|
||||||
|
@ -454,7 +460,7 @@ class PHPExcel_Calculation_FormulaParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
// token accumulation
|
// token accumulation
|
||||||
$value .= $this->_formula{$index};
|
$value .= $this->formula{$index};
|
||||||
++$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
|
// 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
|
// to noop when appropriate, identifying operand and infix-operator subtypes, and pulling "@" from function names
|
||||||
$this->_tokens = array();
|
$this->tokens = array();
|
||||||
|
|
||||||
$tokenCount = count($tokens2);
|
$tokenCount = count($tokens2);
|
||||||
for ($i = 0; $i < $tokenCount; ++$i) {
|
for ($i = 0; $i < $tokenCount; ++$i) {
|
||||||
|
@ -539,53 +545,55 @@ class PHPExcel_Calculation_FormulaParser {
|
||||||
if ($token->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORINFIX && $token->getValue() == "-") {
|
if ($token->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORINFIX && $token->getValue() == "-") {
|
||||||
if ($i == 0) {
|
if ($i == 0) {
|
||||||
$token->setTokenType(PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORPREFIX);
|
$token->setTokenType(PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORPREFIX);
|
||||||
} else if (
|
} elseif ((($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_FUNCTION) &&
|
||||||
(($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_FUNCTION) && ($previousToken->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_STOP)) ||
|
($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_SUBEXPRESSION) &&
|
||||||
($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORPOSTFIX) ||
|
($previousToken->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_STOP)) ||
|
||||||
($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND)
|
($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORPOSTFIX) ||
|
||||||
) {
|
($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND)) {
|
||||||
$token->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_MATH);
|
$token->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_MATH);
|
||||||
} else {
|
} else {
|
||||||
$token->setTokenType(PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORPREFIX);
|
$token->setTokenType(PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORPREFIX);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_tokens[] = $token;
|
$this->tokens[] = $token;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($token->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORINFIX && $token->getValue() == "+") {
|
if ($token->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORINFIX && $token->getValue() == "+") {
|
||||||
if ($i == 0) {
|
if ($i == 0) {
|
||||||
continue;
|
continue;
|
||||||
} else if (
|
} elseif ((($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_FUNCTION) &&
|
||||||
(($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_FUNCTION) && ($previousToken->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_STOP)) ||
|
($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_SUBEXPRESSION) &&
|
||||||
($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORPOSTFIX) ||
|
($previousToken->getTokenSubType() == PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_STOP)) ||
|
||||||
($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND)
|
($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERATORPOSTFIX) ||
|
||||||
) {
|
($previousToken->getTokenType() == PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_OPERAND)) {
|
||||||
$token->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_MATH);
|
$token->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_MATH);
|
||||||
} else {
|
} else {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_tokens[] = $token;
|
$this->tokens[] = $token;
|
||||||
continue;
|
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) {
|
if (strpos("<>=", substr($token->getValue(), 0, 1)) !== false) {
|
||||||
$token->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_LOGICAL);
|
$token->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_LOGICAL);
|
||||||
} else if ($token->getValue() == "&") {
|
} elseif ($token->getValue() == "&") {
|
||||||
$token->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_CONCATENATION);
|
$token->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_CONCATENATION);
|
||||||
} else {
|
} else {
|
||||||
$token->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_MATH);
|
$token->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_MATH);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_tokens[] = $token;
|
$this->tokens[] = $token;
|
||||||
continue;
|
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 (!is_numeric($token->getValue())) {
|
||||||
if (strtoupper($token->getValue()) == "TRUE" || strtoupper($token->getValue() == "FALSE")) {
|
if (strtoupper($token->getValue()) == "TRUE" || strtoupper($token->getValue() == "FALSE")) {
|
||||||
$token->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_LOGICAL);
|
$token->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_LOGICAL);
|
||||||
|
@ -596,7 +604,7 @@ class PHPExcel_Calculation_FormulaParser {
|
||||||
$token->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_NUMBER);
|
$token->setTokenSubType(PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_NUMBER);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_tokens[] = $token;
|
$this->tokens[] = $token;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -608,7 +616,7 @@ class PHPExcel_Calculation_FormulaParser {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_tokens[] = $token;
|
$this->tokens[] = $token;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,30 @@
|
||||||
<?php
|
<?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
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
*
|
*
|
||||||
|
@ -26,84 +50,54 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/*
|
class PHPExcel_Calculation_FormulaToken
|
||||||
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 {
|
|
||||||
/* Token types */
|
/* Token types */
|
||||||
const TOKEN_TYPE_NOOP = 'Noop';
|
const TOKEN_TYPE_NOOP = 'Noop';
|
||||||
const TOKEN_TYPE_OPERAND = 'Operand';
|
const TOKEN_TYPE_OPERAND = 'Operand';
|
||||||
const TOKEN_TYPE_FUNCTION = 'Function';
|
const TOKEN_TYPE_FUNCTION = 'Function';
|
||||||
const TOKEN_TYPE_SUBEXPRESSION = 'Subexpression';
|
const TOKEN_TYPE_SUBEXPRESSION = 'Subexpression';
|
||||||
const TOKEN_TYPE_ARGUMENT = 'Argument';
|
const TOKEN_TYPE_ARGUMENT = 'Argument';
|
||||||
const TOKEN_TYPE_OPERATORPREFIX = 'OperatorPrefix';
|
const TOKEN_TYPE_OPERATORPREFIX = 'OperatorPrefix';
|
||||||
const TOKEN_TYPE_OPERATORINFIX = 'OperatorInfix';
|
const TOKEN_TYPE_OPERATORINFIX = 'OperatorInfix';
|
||||||
const TOKEN_TYPE_OPERATORPOSTFIX = 'OperatorPostfix';
|
const TOKEN_TYPE_OPERATORPOSTFIX = 'OperatorPostfix';
|
||||||
const TOKEN_TYPE_WHITESPACE = 'Whitespace';
|
const TOKEN_TYPE_WHITESPACE = 'Whitespace';
|
||||||
const TOKEN_TYPE_UNKNOWN = 'Unknown';
|
const TOKEN_TYPE_UNKNOWN = 'Unknown';
|
||||||
|
|
||||||
/* Token subtypes */
|
/* Token subtypes */
|
||||||
const TOKEN_SUBTYPE_NOTHING = 'Nothing';
|
const TOKEN_SUBTYPE_NOTHING = 'Nothing';
|
||||||
const TOKEN_SUBTYPE_START = 'Start';
|
const TOKEN_SUBTYPE_START = 'Start';
|
||||||
const TOKEN_SUBTYPE_STOP = 'Stop';
|
const TOKEN_SUBTYPE_STOP = 'Stop';
|
||||||
const TOKEN_SUBTYPE_TEXT = 'Text';
|
const TOKEN_SUBTYPE_TEXT = 'Text';
|
||||||
const TOKEN_SUBTYPE_NUMBER = 'Number';
|
const TOKEN_SUBTYPE_NUMBER = 'Number';
|
||||||
const TOKEN_SUBTYPE_LOGICAL = 'Logical';
|
const TOKEN_SUBTYPE_LOGICAL = 'Logical';
|
||||||
const TOKEN_SUBTYPE_ERROR = 'Error';
|
const TOKEN_SUBTYPE_ERROR = 'Error';
|
||||||
const TOKEN_SUBTYPE_RANGE = 'Range';
|
const TOKEN_SUBTYPE_RANGE = 'Range';
|
||||||
const TOKEN_SUBTYPE_MATH = 'Math';
|
const TOKEN_SUBTYPE_MATH = 'Math';
|
||||||
const TOKEN_SUBTYPE_CONCATENATION = 'Concatenation';
|
const TOKEN_SUBTYPE_CONCATENATION = 'Concatenation';
|
||||||
const TOKEN_SUBTYPE_INTERSECTION = 'Intersection';
|
const TOKEN_SUBTYPE_INTERSECTION = 'Intersection';
|
||||||
const TOKEN_SUBTYPE_UNION = 'Union';
|
const TOKEN_SUBTYPE_UNION = 'Union';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Value
|
* Value
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_value;
|
private $value;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Token Type (represented by TOKEN_TYPE_*)
|
* Token Type (represented by TOKEN_TYPE_*)
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_tokenType;
|
private $tokenType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Token SubType (represented by TOKEN_SUBTYPE_*)
|
* Token SubType (represented by TOKEN_SUBTYPE_*)
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_tokenSubType;
|
private $tokenSubType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new PHPExcel_Calculation_FormulaToken
|
* 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)
|
public function __construct($pValue, $pTokenType = PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_UNKNOWN, $pTokenSubType = PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_NOTHING)
|
||||||
{
|
{
|
||||||
// Initialise values
|
// Initialise values
|
||||||
$this->_value = $pValue;
|
$this->value = $pValue;
|
||||||
$this->_tokenType = $pTokenType;
|
$this->tokenType = $pTokenType;
|
||||||
$this->_tokenSubType = $pTokenSubType;
|
$this->tokenSubType = $pTokenSubType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -125,8 +119,9 @@ class PHPExcel_Calculation_FormulaToken {
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getValue() {
|
public function getValue()
|
||||||
return $this->_value;
|
{
|
||||||
|
return $this->value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -134,8 +129,9 @@ class PHPExcel_Calculation_FormulaToken {
|
||||||
*
|
*
|
||||||
* @param string $value
|
* @param string $value
|
||||||
*/
|
*/
|
||||||
public function setValue($value) {
|
public function setValue($value)
|
||||||
$this->_value = $value;
|
{
|
||||||
|
$this->value = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -143,8 +139,9 @@ class PHPExcel_Calculation_FormulaToken {
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getTokenType() {
|
public function getTokenType()
|
||||||
return $this->_tokenType;
|
{
|
||||||
|
return $this->tokenType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -152,8 +149,9 @@ class PHPExcel_Calculation_FormulaToken {
|
||||||
*
|
*
|
||||||
* @param string $value
|
* @param string $value
|
||||||
*/
|
*/
|
||||||
public function setTokenType($value = PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_UNKNOWN) {
|
public function setTokenType($value = PHPExcel_Calculation_FormulaToken::TOKEN_TYPE_UNKNOWN)
|
||||||
$this->_tokenType = $value;
|
{
|
||||||
|
$this->tokenType = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -161,8 +159,9 @@ class PHPExcel_Calculation_FormulaToken {
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getTokenSubType() {
|
public function getTokenSubType()
|
||||||
return $this->_tokenSubType;
|
{
|
||||||
|
return $this->tokenSubType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -170,7 +169,8 @@ class PHPExcel_Calculation_FormulaToken {
|
||||||
*
|
*
|
||||||
* @param string $value
|
* @param string $value
|
||||||
*/
|
*/
|
||||||
public function setTokenSubType($value = PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_NOTHING) {
|
public function setTokenSubType($value = PHPExcel_Calculation_FormulaToken::TOKEN_SUBTYPE_NOTHING)
|
||||||
$this->_tokenSubType = $value;
|
{
|
||||||
|
$this->tokenSubType = $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel_Calculation_Function
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2015 PHPExcel
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
*
|
*
|
||||||
|
@ -24,49 +25,41 @@
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
class PHPExcel_Calculation_Function
|
||||||
|
{
|
||||||
/**
|
|
||||||
* PHPExcel_Calculation_Function
|
|
||||||
*
|
|
||||||
* @category PHPExcel
|
|
||||||
* @package PHPExcel_Calculation
|
|
||||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
|
||||||
*/
|
|
||||||
class PHPExcel_Calculation_Function {
|
|
||||||
/* Function categories */
|
/* Function categories */
|
||||||
const CATEGORY_CUBE = 'Cube';
|
const CATEGORY_CUBE = 'Cube';
|
||||||
const CATEGORY_DATABASE = 'Database';
|
const CATEGORY_DATABASE = 'Database';
|
||||||
const CATEGORY_DATE_AND_TIME = 'Date and Time';
|
const CATEGORY_DATE_AND_TIME = 'Date and Time';
|
||||||
const CATEGORY_ENGINEERING = 'Engineering';
|
const CATEGORY_ENGINEERING = 'Engineering';
|
||||||
const CATEGORY_FINANCIAL = 'Financial';
|
const CATEGORY_FINANCIAL = 'Financial';
|
||||||
const CATEGORY_INFORMATION = 'Information';
|
const CATEGORY_INFORMATION = 'Information';
|
||||||
const CATEGORY_LOGICAL = 'Logical';
|
const CATEGORY_LOGICAL = 'Logical';
|
||||||
const CATEGORY_LOOKUP_AND_REFERENCE = 'Lookup and Reference';
|
const CATEGORY_LOOKUP_AND_REFERENCE = 'Lookup and Reference';
|
||||||
const CATEGORY_MATH_AND_TRIG = 'Math and Trig';
|
const CATEGORY_MATH_AND_TRIG = 'Math and Trig';
|
||||||
const CATEGORY_STATISTICAL = 'Statistical';
|
const CATEGORY_STATISTICAL = 'Statistical';
|
||||||
const CATEGORY_TEXT_AND_DATA = 'Text and Data';
|
const CATEGORY_TEXT_AND_DATA = 'Text and Data';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Category (represented by CATEGORY_*)
|
* Category (represented by CATEGORY_*)
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_category;
|
private $category;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Excel name
|
* Excel name
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_excelName;
|
private $excelName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel name
|
* PHPExcel name
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_phpExcelName;
|
private $phpExcelName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new PHPExcel_Calculation_Function
|
* Create a new PHPExcel_Calculation_Function
|
||||||
|
@ -76,13 +69,13 @@ class PHPExcel_Calculation_Function {
|
||||||
* @param string $pPHPExcelName PHPExcel function mapping
|
* @param string $pPHPExcelName PHPExcel function mapping
|
||||||
* @throws PHPExcel_Calculation_Exception
|
* @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
|
// Initialise values
|
||||||
$this->_category = $pCategory;
|
$this->category = $pCategory;
|
||||||
$this->_excelName = $pExcelName;
|
$this->excelName = $pExcelName;
|
||||||
$this->_phpExcelName = $pPHPExcelName;
|
$this->phpExcelName = $pPHPExcelName;
|
||||||
} else {
|
} else {
|
||||||
throw new PHPExcel_Calculation_Exception("Invalid parameters passed.");
|
throw new PHPExcel_Calculation_Exception("Invalid parameters passed.");
|
||||||
}
|
}
|
||||||
|
@ -93,8 +86,9 @@ class PHPExcel_Calculation_Function {
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getCategory() {
|
public function getCategory()
|
||||||
return $this->_category;
|
{
|
||||||
|
return $this->category;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -103,9 +97,10 @@ class PHPExcel_Calculation_Function {
|
||||||
* @param string $value
|
* @param string $value
|
||||||
* @throws PHPExcel_Calculation_Exception
|
* @throws PHPExcel_Calculation_Exception
|
||||||
*/
|
*/
|
||||||
public function setCategory($value = null) {
|
public function setCategory($value = null)
|
||||||
|
{
|
||||||
if (!is_null($value)) {
|
if (!is_null($value)) {
|
||||||
$this->_category = $value;
|
$this->category = $value;
|
||||||
} else {
|
} else {
|
||||||
throw new PHPExcel_Calculation_Exception("Invalid parameter passed.");
|
throw new PHPExcel_Calculation_Exception("Invalid parameter passed.");
|
||||||
}
|
}
|
||||||
|
@ -116,8 +111,9 @@ class PHPExcel_Calculation_Function {
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getExcelName() {
|
public function getExcelName()
|
||||||
return $this->_excelName;
|
{
|
||||||
|
return $this->excelName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -125,8 +121,9 @@ class PHPExcel_Calculation_Function {
|
||||||
*
|
*
|
||||||
* @param string $value
|
* @param string $value
|
||||||
*/
|
*/
|
||||||
public function setExcelName($value) {
|
public function setExcelName($value)
|
||||||
$this->_excelName = $value;
|
{
|
||||||
|
$this->excelName = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -134,8 +131,9 @@ class PHPExcel_Calculation_Function {
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getPHPExcelName() {
|
public function getPHPExcelName()
|
||||||
return $this->_phpExcelName;
|
{
|
||||||
|
return $this->phpExcelName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -143,7 +141,8 @@ class PHPExcel_Calculation_Function {
|
||||||
*
|
*
|
||||||
* @param string $value
|
* @param string $value
|
||||||
*/
|
*/
|
||||||
public function setPHPExcelName($value) {
|
public function setPHPExcelName($value)
|
||||||
$this->_phpExcelName = $value;
|
{
|
||||||
|
$this->phpExcelName = $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,30 +1,4 @@
|
||||||
<?php
|
<?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 */
|
/** PHPExcel root directory */
|
||||||
if (!defined('PHPEXCEL_ROOT')) {
|
if (!defined('PHPEXCEL_ROOT')) {
|
||||||
|
@ -52,20 +26,39 @@ define('PRECISION', 8.88E-016);
|
||||||
/**
|
/**
|
||||||
* PHPExcel_Calculation_Functions
|
* 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
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Calculation
|
* @package PHPExcel_Calculation
|
||||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @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 */
|
/** constants */
|
||||||
const COMPATIBILITY_EXCEL = 'Excel';
|
const COMPATIBILITY_EXCEL = 'Excel';
|
||||||
const COMPATIBILITY_GNUMERIC = 'Gnumeric';
|
const COMPATIBILITY_GNUMERIC = 'Gnumeric';
|
||||||
const COMPATIBILITY_OPENOFFICE = 'OpenOfficeCalc';
|
const COMPATIBILITY_OPENOFFICE = 'OpenOfficeCalc';
|
||||||
|
|
||||||
const RETURNDATE_PHP_NUMERIC = 'P';
|
const RETURNDATE_PHP_NUMERIC = 'P';
|
||||||
const RETURNDATE_PHP_OBJECT = 'O';
|
const RETURNDATE_PHP_OBJECT = 'O';
|
||||||
const RETURNDATE_EXCEL = 'E';
|
const RETURNDATE_EXCEL = 'E';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -90,15 +83,16 @@ class PHPExcel_Calculation_Functions {
|
||||||
* @access private
|
* @access private
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected static $_errorCodes = array( 'null' => '#NULL!',
|
protected static $_errorCodes = array(
|
||||||
'divisionbyzero' => '#DIV/0!',
|
'null' => '#NULL!',
|
||||||
'value' => '#VALUE!',
|
'divisionbyzero' => '#DIV/0!',
|
||||||
'reference' => '#REF!',
|
'value' => '#VALUE!',
|
||||||
'name' => '#NAME?',
|
'reference' => '#REF!',
|
||||||
'num' => '#NUM!',
|
'name' => '#NAME?',
|
||||||
'na' => '#N/A',
|
'num' => '#NUM!',
|
||||||
'gettingdata' => '#GETTING_DATA'
|
'na' => '#N/A',
|
||||||
);
|
'gettingdata' => '#GETTING_DATA'
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -113,15 +107,16 @@ class PHPExcel_Calculation_Functions {
|
||||||
* PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE 'OpenOfficeCalc'
|
* PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE 'OpenOfficeCalc'
|
||||||
* @return boolean (Success or Failure)
|
* @return boolean (Success or Failure)
|
||||||
*/
|
*/
|
||||||
public static function setCompatibilityMode($compatibilityMode) {
|
public static function setCompatibilityMode($compatibilityMode)
|
||||||
|
{
|
||||||
if (($compatibilityMode == self::COMPATIBILITY_EXCEL) ||
|
if (($compatibilityMode == self::COMPATIBILITY_EXCEL) ||
|
||||||
($compatibilityMode == self::COMPATIBILITY_GNUMERIC) ||
|
($compatibilityMode == self::COMPATIBILITY_GNUMERIC) ||
|
||||||
($compatibilityMode == self::COMPATIBILITY_OPENOFFICE)) {
|
($compatibilityMode == self::COMPATIBILITY_OPENOFFICE)) {
|
||||||
self::$compatibilityMode = $compatibilityMode;
|
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_GNUMERIC 'Gnumeric'
|
||||||
* PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE 'OpenOfficeCalc'
|
* PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE 'OpenOfficeCalc'
|
||||||
*/
|
*/
|
||||||
public static function getCompatibilityMode() {
|
public static function getCompatibilityMode()
|
||||||
|
{
|
||||||
return self::$compatibilityMode;
|
return self::$compatibilityMode;
|
||||||
} // function getCompatibilityMode()
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -152,15 +148,16 @@ class PHPExcel_Calculation_Functions {
|
||||||
* PHPExcel_Calculation_Functions::RETURNDATE_EXCEL 'E'
|
* PHPExcel_Calculation_Functions::RETURNDATE_EXCEL 'E'
|
||||||
* @return boolean Success or failure
|
* @return boolean Success or failure
|
||||||
*/
|
*/
|
||||||
public static function setReturnDateType($returnDateType) {
|
public static function setReturnDateType($returnDateType)
|
||||||
|
{
|
||||||
if (($returnDateType == self::RETURNDATE_PHP_NUMERIC) ||
|
if (($returnDateType == self::RETURNDATE_PHP_NUMERIC) ||
|
||||||
($returnDateType == self::RETURNDATE_PHP_OBJECT) ||
|
($returnDateType == self::RETURNDATE_PHP_OBJECT) ||
|
||||||
($returnDateType == self::RETURNDATE_EXCEL)) {
|
($returnDateType == self::RETURNDATE_EXCEL)) {
|
||||||
self::$ReturnDateType = $returnDateType;
|
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_PHP_OBJECT 'O'
|
||||||
* PHPExcel_Calculation_Functions::RETURNDATE_EXCEL 'E'
|
* PHPExcel_Calculation_Functions::RETURNDATE_EXCEL 'E'
|
||||||
*/
|
*/
|
||||||
public static function getReturnDateType() {
|
public static function getReturnDateType()
|
||||||
|
{
|
||||||
return self::$ReturnDateType;
|
return self::$ReturnDateType;
|
||||||
} // function getReturnDateType()
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -186,9 +184,10 @@ class PHPExcel_Calculation_Functions {
|
||||||
* @category Error Returns
|
* @category Error Returns
|
||||||
* @return string #Not Yet Implemented
|
* @return string #Not Yet Implemented
|
||||||
*/
|
*/
|
||||||
public static function DUMMY() {
|
public static function DUMMY()
|
||||||
|
{
|
||||||
return '#Not Yet Implemented';
|
return '#Not Yet Implemented';
|
||||||
} // function DUMMY()
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -198,9 +197,10 @@ class PHPExcel_Calculation_Functions {
|
||||||
* @category Error Returns
|
* @category Error Returns
|
||||||
* @return string #Not Yet Implemented
|
* @return string #Not Yet Implemented
|
||||||
*/
|
*/
|
||||||
public static function DIV0() {
|
public static function DIV0()
|
||||||
|
{
|
||||||
return self::$_errorCodes['divisionbyzero'];
|
return self::$_errorCodes['divisionbyzero'];
|
||||||
} // function DIV0()
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -216,9 +216,10 @@ class PHPExcel_Calculation_Functions {
|
||||||
* @category Logical Functions
|
* @category Logical Functions
|
||||||
* @return string #N/A!
|
* @return string #N/A!
|
||||||
*/
|
*/
|
||||||
public static function NA() {
|
public static function NA()
|
||||||
|
{
|
||||||
return self::$_errorCodes['na'];
|
return self::$_errorCodes['na'];
|
||||||
} // function NA()
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -230,9 +231,10 @@ class PHPExcel_Calculation_Functions {
|
||||||
* @category Error Returns
|
* @category Error Returns
|
||||||
* @return string #NUM!
|
* @return string #NUM!
|
||||||
*/
|
*/
|
||||||
public static function NaN() {
|
public static function NaN()
|
||||||
|
{
|
||||||
return self::$_errorCodes['num'];
|
return self::$_errorCodes['num'];
|
||||||
} // function NaN()
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -244,9 +246,10 @@ class PHPExcel_Calculation_Functions {
|
||||||
* @category Error Returns
|
* @category Error Returns
|
||||||
* @return string #NAME?
|
* @return string #NAME?
|
||||||
*/
|
*/
|
||||||
public static function NAME() {
|
public static function NAME()
|
||||||
|
{
|
||||||
return self::$_errorCodes['name'];
|
return self::$_errorCodes['name'];
|
||||||
} // function NAME()
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -258,9 +261,10 @@ class PHPExcel_Calculation_Functions {
|
||||||
* @category Error Returns
|
* @category Error Returns
|
||||||
* @return string #REF!
|
* @return string #REF!
|
||||||
*/
|
*/
|
||||||
public static function REF() {
|
public static function REF()
|
||||||
|
{
|
||||||
return self::$_errorCodes['reference'];
|
return self::$_errorCodes['reference'];
|
||||||
} // function REF()
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -272,9 +276,10 @@ class PHPExcel_Calculation_Functions {
|
||||||
* @category Error Returns
|
* @category Error Returns
|
||||||
* @return string #NULL!
|
* @return string #NULL!
|
||||||
*/
|
*/
|
||||||
public static function NULL() {
|
public static function NULL()
|
||||||
|
{
|
||||||
return self::$_errorCodes['null'];
|
return self::$_errorCodes['null'];
|
||||||
} // function NULL()
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -286,36 +291,44 @@ class PHPExcel_Calculation_Functions {
|
||||||
* @category Error Returns
|
* @category Error Returns
|
||||||
* @return string #VALUE!
|
* @return string #VALUE!
|
||||||
*/
|
*/
|
||||||
public static function VALUE() {
|
public static function VALUE()
|
||||||
|
{
|
||||||
return self::$_errorCodes['value'];
|
return self::$_errorCodes['value'];
|
||||||
} // function VALUE()
|
|
||||||
|
|
||||||
|
|
||||||
public static function isMatrixValue($idx) {
|
|
||||||
return ((substr_count($idx,'.') <= 1) || (preg_match('/\.[A-Z]/',$idx) > 0));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static function isValue($idx) {
|
public static function isMatrixValue($idx)
|
||||||
return (substr_count($idx,'.') == 0);
|
{
|
||||||
|
return ((substr_count($idx, '.') <= 1) || (preg_match('/\.[A-Z]/', $idx) > 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static function isCellValue($idx) {
|
public static function isValue($idx)
|
||||||
return (substr_count($idx,'.') > 1);
|
{
|
||||||
|
return (substr_count($idx, '.') == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static function _ifCondition($condition) {
|
public static function isCellValue($idx)
|
||||||
|
{
|
||||||
|
return (substr_count($idx, '.') > 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static function _ifCondition($condition)
|
||||||
|
{
|
||||||
$condition = PHPExcel_Calculation_Functions::flattenSingleValue($condition);
|
$condition = PHPExcel_Calculation_Functions::flattenSingleValue($condition);
|
||||||
if (!isset($condition{0}))
|
if (!isset($condition{0})) {
|
||||||
$condition = '=""';
|
$condition = '=""';
|
||||||
if (!in_array($condition{0},array('>', '<', '='))) {
|
}
|
||||||
if (!is_numeric($condition)) { $condition = PHPExcel_Calculation::_wrapResult(strtoupper($condition)); }
|
if (!in_array($condition{0}, array('>', '<', '='))) {
|
||||||
return '='.$condition;
|
if (!is_numeric($condition)) {
|
||||||
|
$condition = PHPExcel_Calculation::_wrapResult(strtoupper($condition));
|
||||||
|
}
|
||||||
|
return '=' . $condition;
|
||||||
} else {
|
} else {
|
||||||
preg_match('/([<>=]+)(.*)/',$condition,$matches);
|
preg_match('/([<>=]+)(.*)/', $condition, $matches);
|
||||||
list(,$operator,$operand) = $matches;
|
list(, $operator, $operand) = $matches;
|
||||||
|
|
||||||
if (!is_numeric($operand)) {
|
if (!is_numeric($operand)) {
|
||||||
$operand = str_replace('"', '""', $operand);
|
$operand = str_replace('"', '""', $operand);
|
||||||
|
@ -324,8 +337,7 @@ class PHPExcel_Calculation_Functions {
|
||||||
|
|
||||||
return $operator.$operand;
|
return $operator.$operand;
|
||||||
}
|
}
|
||||||
} // function _ifCondition()
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ERROR_TYPE
|
* ERROR_TYPE
|
||||||
|
@ -333,18 +345,19 @@ class PHPExcel_Calculation_Functions {
|
||||||
* @param mixed $value Value to check
|
* @param mixed $value Value to check
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public static function ERROR_TYPE($value = '') {
|
public static function ERROR_TYPE($value = '')
|
||||||
$value = self::flattenSingleValue($value);
|
{
|
||||||
|
$value = self::flattenSingleValue($value);
|
||||||
|
|
||||||
$i = 1;
|
$i = 1;
|
||||||
foreach(self::$_errorCodes as $errorCode) {
|
foreach (self::$_errorCodes as $errorCode) {
|
||||||
if ($value === $errorCode) {
|
if ($value === $errorCode) {
|
||||||
return $i;
|
return $i;
|
||||||
}
|
}
|
||||||
++$i;
|
++$i;
|
||||||
}
|
}
|
||||||
return self::NA();
|
return self::NA();
|
||||||
} // function ERROR_TYPE()
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -353,13 +366,14 @@ class PHPExcel_Calculation_Functions {
|
||||||
* @param mixed $value Value to check
|
* @param mixed $value Value to check
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public static function IS_BLANK($value = NULL) {
|
public static function IS_BLANK($value = null)
|
||||||
|
{
|
||||||
if (!is_null($value)) {
|
if (!is_null($value)) {
|
||||||
$value = self::flattenSingleValue($value);
|
$value = self::flattenSingleValue($value);
|
||||||
}
|
}
|
||||||
|
|
||||||
return is_null($value);
|
return is_null($value);
|
||||||
} // function IS_BLANK()
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -368,11 +382,12 @@ class PHPExcel_Calculation_Functions {
|
||||||
* @param mixed $value Value to check
|
* @param mixed $value Value to check
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public static function IS_ERR($value = '') {
|
public static function IS_ERR($value = '')
|
||||||
$value = self::flattenSingleValue($value);
|
{
|
||||||
|
$value = self::flattenSingleValue($value);
|
||||||
|
|
||||||
return self::IS_ERROR($value) && (!self::IS_NA($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
|
* @param mixed $value Value to check
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public static function IS_ERROR($value = '') {
|
public static function IS_ERROR($value = '')
|
||||||
$value = self::flattenSingleValue($value);
|
{
|
||||||
|
$value = self::flattenSingleValue($value);
|
||||||
|
|
||||||
if (!is_string($value))
|
if (!is_string($value)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
return in_array($value, array_values(self::$_errorCodes));
|
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
|
* @param mixed $value Value to check
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public static function IS_NA($value = '') {
|
public static function IS_NA($value = '')
|
||||||
$value = self::flattenSingleValue($value);
|
{
|
||||||
|
$value = self::flattenSingleValue($value);
|
||||||
|
|
||||||
return ($value === self::NA());
|
return ($value === self::NA());
|
||||||
} // function IS_NA()
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -409,15 +427,18 @@ class PHPExcel_Calculation_Functions {
|
||||||
* @param mixed $value Value to check
|
* @param mixed $value Value to check
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public static function IS_EVEN($value = NULL) {
|
public static function IS_EVEN($value = null)
|
||||||
|
{
|
||||||
$value = self::flattenSingleValue($value);
|
$value = self::flattenSingleValue($value);
|
||||||
|
|
||||||
if ($value === NULL)
|
if ($value === null) {
|
||||||
return self::NAME();
|
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 self::VALUE();
|
||||||
|
}
|
||||||
|
|
||||||
return ($value % 2 == 0);
|
return ($value % 2 == 0);
|
||||||
} // function IS_EVEN()
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -426,15 +447,18 @@ class PHPExcel_Calculation_Functions {
|
||||||
* @param mixed $value Value to check
|
* @param mixed $value Value to check
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public static function IS_ODD($value = NULL) {
|
public static function IS_ODD($value = null)
|
||||||
|
{
|
||||||
$value = self::flattenSingleValue($value);
|
$value = self::flattenSingleValue($value);
|
||||||
|
|
||||||
if ($value === NULL)
|
if ($value === null) {
|
||||||
return self::NAME();
|
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 self::VALUE();
|
||||||
|
}
|
||||||
|
|
||||||
return (abs($value) % 2 == 1);
|
return (abs($value) % 2 == 1);
|
||||||
} // function IS_ODD()
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -443,14 +467,15 @@ class PHPExcel_Calculation_Functions {
|
||||||
* @param mixed $value Value to check
|
* @param mixed $value Value to check
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public static function IS_NUMBER($value = NULL) {
|
public static function IS_NUMBER($value = null)
|
||||||
$value = self::flattenSingleValue($value);
|
{
|
||||||
|
$value = self::flattenSingleValue($value);
|
||||||
|
|
||||||
if (is_string($value)) {
|
if (is_string($value)) {
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
return is_numeric($value);
|
return is_numeric($value);
|
||||||
} // function IS_NUMBER()
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -459,11 +484,12 @@ class PHPExcel_Calculation_Functions {
|
||||||
* @param mixed $value Value to check
|
* @param mixed $value Value to check
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public static function IS_LOGICAL($value = NULL) {
|
public static function IS_LOGICAL($value = null)
|
||||||
$value = self::flattenSingleValue($value);
|
{
|
||||||
|
$value = self::flattenSingleValue($value);
|
||||||
|
|
||||||
return is_bool($value);
|
return is_bool($value);
|
||||||
} // function IS_LOGICAL()
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -472,11 +498,12 @@ class PHPExcel_Calculation_Functions {
|
||||||
* @param mixed $value Value to check
|
* @param mixed $value Value to check
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public static function IS_TEXT($value = NULL) {
|
public static function IS_TEXT($value = null)
|
||||||
$value = self::flattenSingleValue($value);
|
{
|
||||||
|
$value = self::flattenSingleValue($value);
|
||||||
|
|
||||||
return (is_string($value) && !self::IS_ERROR($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
|
* @param mixed $value Value to check
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public static function IS_NONTEXT($value = NULL) {
|
public static function IS_NONTEXT($value = null)
|
||||||
|
{
|
||||||
return !self::IS_TEXT($value);
|
return !self::IS_TEXT($value);
|
||||||
} // function IS_NONTEXT()
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -495,9 +523,10 @@ class PHPExcel_Calculation_Functions {
|
||||||
*
|
*
|
||||||
* @return string Version information
|
* @return string Version information
|
||||||
*/
|
*/
|
||||||
public static function VERSION() {
|
public static function VERSION()
|
||||||
|
{
|
||||||
return 'PHPExcel ##VERSION##, ##DATE##';
|
return 'PHPExcel ##VERSION##, ##DATE##';
|
||||||
} // function VERSION()
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -515,21 +544,22 @@ class PHPExcel_Calculation_Functions {
|
||||||
* An error value The error value
|
* An error value The error value
|
||||||
* Anything else 0
|
* Anything else 0
|
||||||
*/
|
*/
|
||||||
public static function N($value = NULL) {
|
public static function N($value = null)
|
||||||
|
{
|
||||||
while (is_array($value)) {
|
while (is_array($value)) {
|
||||||
$value = array_shift($value);
|
$value = array_shift($value);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (gettype($value)) {
|
switch (gettype($value)) {
|
||||||
case 'double' :
|
case 'double':
|
||||||
case 'float' :
|
case 'float':
|
||||||
case 'integer' :
|
case 'integer':
|
||||||
return $value;
|
return $value;
|
||||||
break;
|
break;
|
||||||
case 'boolean' :
|
case 'boolean':
|
||||||
return (integer) $value;
|
return (integer) $value;
|
||||||
break;
|
break;
|
||||||
case 'string' :
|
case 'string':
|
||||||
// Errors
|
// Errors
|
||||||
if ((strlen($value) > 0) && ($value{0} == '#')) {
|
if ((strlen($value) > 0) && ($value{0} == '#')) {
|
||||||
return $value;
|
return $value;
|
||||||
|
@ -537,7 +567,7 @@ class PHPExcel_Calculation_Functions {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
} // function N()
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -554,11 +584,12 @@ class PHPExcel_Calculation_Functions {
|
||||||
* An error value 16
|
* An error value 16
|
||||||
* Array or Matrix 64
|
* Array or Matrix 64
|
||||||
*/
|
*/
|
||||||
public static function TYPE($value = NULL) {
|
public static function TYPE($value = null)
|
||||||
$value = self::flattenArrayIndexed($value);
|
{
|
||||||
|
$value = self::flattenArrayIndexed($value);
|
||||||
if (is_array($value) && (count($value) > 1)) {
|
if (is_array($value) && (count($value) > 1)) {
|
||||||
$a = array_keys($value);
|
end($value);
|
||||||
$a = array_pop($a);
|
$a = key($value);
|
||||||
// Range of cells is an error
|
// Range of cells is an error
|
||||||
if (self::isCellValue($a)) {
|
if (self::isCellValue($a)) {
|
||||||
return 16;
|
return 16;
|
||||||
|
@ -566,19 +597,19 @@ class PHPExcel_Calculation_Functions {
|
||||||
} elseif (self::isMatrixValue($a)) {
|
} elseif (self::isMatrixValue($a)) {
|
||||||
return 64;
|
return 64;
|
||||||
}
|
}
|
||||||
} elseif(empty($value)) {
|
} elseif (empty($value)) {
|
||||||
// Empty Cell
|
// Empty Cell
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
$value = self::flattenSingleValue($value);
|
$value = self::flattenSingleValue($value);
|
||||||
|
|
||||||
if (($value === NULL) || (is_float($value)) || (is_int($value))) {
|
if (($value === null) || (is_float($value)) || (is_int($value))) {
|
||||||
return 1;
|
return 1;
|
||||||
} elseif(is_bool($value)) {
|
} elseif (is_bool($value)) {
|
||||||
return 4;
|
return 4;
|
||||||
} elseif(is_array($value)) {
|
} elseif (is_array($value)) {
|
||||||
return 64;
|
return 64;
|
||||||
} elseif(is_string($value)) {
|
} elseif (is_string($value)) {
|
||||||
// Errors
|
// Errors
|
||||||
if ((strlen($value) > 0) && ($value{0} == '#')) {
|
if ((strlen($value) > 0) && ($value{0} == '#')) {
|
||||||
return 16;
|
return 16;
|
||||||
|
@ -586,7 +617,7 @@ class PHPExcel_Calculation_Functions {
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
} // function TYPE()
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -595,7 +626,8 @@ class PHPExcel_Calculation_Functions {
|
||||||
* @param array $array Array to be flattened
|
* @param array $array Array to be flattened
|
||||||
* @return array Flattened array
|
* @return array Flattened array
|
||||||
*/
|
*/
|
||||||
public static function flattenArray($array) {
|
public static function flattenArray($array)
|
||||||
|
{
|
||||||
if (!is_array($array)) {
|
if (!is_array($array)) {
|
||||||
return (array) $array;
|
return (array) $array;
|
||||||
}
|
}
|
||||||
|
@ -618,7 +650,7 @@ class PHPExcel_Calculation_Functions {
|
||||||
}
|
}
|
||||||
|
|
||||||
return $arrayValues;
|
return $arrayValues;
|
||||||
} // function flattenArray()
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -627,7 +659,8 @@ class PHPExcel_Calculation_Functions {
|
||||||
* @param array $array Array to be flattened
|
* @param array $array Array to be flattened
|
||||||
* @return array Flattened array
|
* @return array Flattened array
|
||||||
*/
|
*/
|
||||||
public static function flattenArrayIndexed($array) {
|
public static function flattenArrayIndexed($array)
|
||||||
|
{
|
||||||
if (!is_array($array)) {
|
if (!is_array($array)) {
|
||||||
return (array) $array;
|
return (array) $array;
|
||||||
}
|
}
|
||||||
|
@ -650,7 +683,7 @@ class PHPExcel_Calculation_Functions {
|
||||||
}
|
}
|
||||||
|
|
||||||
return $arrayValues;
|
return $arrayValues;
|
||||||
} // function flattenArrayIndexed()
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -659,15 +692,15 @@ class PHPExcel_Calculation_Functions {
|
||||||
* @param mixed $value Array or scalar value
|
* @param mixed $value Array or scalar value
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public static function flattenSingleValue($value = '') {
|
public static function flattenSingleValue($value = '')
|
||||||
|
{
|
||||||
while (is_array($value)) {
|
while (is_array($value)) {
|
||||||
$value = array_pop($value);
|
$value = array_pop($value);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $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
|
// So we test if they do exist for this version of PHP/operating platform; and if not we create them
|
||||||
//
|
//
|
||||||
if (!function_exists('acosh')) {
|
if (!function_exists('acosh')) {
|
||||||
function acosh($x) {
|
function acosh($x)
|
||||||
|
{
|
||||||
return 2 * log(sqrt(($x + 1) / 2) + sqrt(($x - 1) / 2));
|
return 2 * log(sqrt(($x + 1) / 2) + sqrt(($x - 1) / 2));
|
||||||
} // function acosh()
|
} // function acosh()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!function_exists('asinh')) {
|
if (!function_exists('asinh')) {
|
||||||
function asinh($x) {
|
function asinh($x)
|
||||||
|
{
|
||||||
return log($x + sqrt(1 + $x * $x));
|
return log($x + sqrt(1 + $x * $x));
|
||||||
} // function asinh()
|
} // function asinh()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!function_exists('atanh')) {
|
if (!function_exists('atanh')) {
|
||||||
function atanh($x) {
|
function atanh($x)
|
||||||
|
{
|
||||||
return (log(1 + $x) - log(1 - $x)) / 2;
|
return (log(1 + $x) - log(1 - $x)) / 2;
|
||||||
} // function atanh()
|
} // function atanh()
|
||||||
}
|
}
|
||||||
|
@ -700,22 +736,23 @@ if (!function_exists('atanh')) {
|
||||||
//
|
//
|
||||||
if ((!function_exists('mb_str_replace')) &&
|
if ((!function_exists('mb_str_replace')) &&
|
||||||
(function_exists('mb_substr')) && (function_exists('mb_strlen')) && (function_exists('mb_strpos'))) {
|
(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)) {
|
{
|
||||||
|
if (is_array($subject)) {
|
||||||
$ret = array();
|
$ret = array();
|
||||||
foreach($subject as $key => $val) {
|
foreach ($subject as $key => $val) {
|
||||||
$ret[$key] = mb_str_replace($search, $replace, $val);
|
$ret[$key] = mb_str_replace($search, $replace, $val);
|
||||||
}
|
}
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach((array) $search as $key => $s) {
|
foreach ((array) $search as $key => $s) {
|
||||||
if($s == '' && $s !== 0) {
|
if ($s == '' && $s !== 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$r = !is_array($replace) ? $replace : (array_key_exists($key, $replace) ? $replace[$key] : '');
|
$r = !is_array($replace) ? $replace : (array_key_exists($key, $replace) ? $replace[$key] : '');
|
||||||
$pos = mb_strpos($subject, $s, 0, 'UTF-8');
|
$pos = mb_strpos($subject, $s, 0, 'UTF-8');
|
||||||
while($pos !== false) {
|
while ($pos !== false) {
|
||||||
$subject = mb_substr($subject, 0, $pos, 'UTF-8') . $r . mb_substr($subject, $pos + mb_strlen($s, 'UTF-8'), 65535, 'UTF-8');
|
$subject = mb_substr($subject, 0, $pos, 'UTF-8') . $r . mb_substr($subject, $pos + mb_strlen($s, 'UTF-8'), 65535, 'UTF-8');
|
||||||
$pos = mb_strpos($subject, $s, $pos + mb_strlen($r, 'UTF-8'), 'UTF-8');
|
$pos = mb_strpos($subject, $s, $pos + mb_strlen($r, 'UTF-8'), 'UTF-8');
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,16 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/** PHPExcel root directory */
|
||||||
|
if (!defined('PHPEXCEL_ROOT')) {
|
||||||
|
/**
|
||||||
|
* @ignore
|
||||||
|
*/
|
||||||
|
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||||
|
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel_Calculation_Logical
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2015 PHPExcel
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
*
|
*
|
||||||
|
@ -24,27 +34,8 @@
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
class PHPExcel_Calculation_Logical
|
||||||
|
{
|
||||||
/** 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 {
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TRUE
|
* TRUE
|
||||||
*
|
*
|
||||||
|
@ -57,9 +48,10 @@ class PHPExcel_Calculation_Logical {
|
||||||
* @category Logical Functions
|
* @category Logical Functions
|
||||||
* @return boolean True
|
* @return boolean True
|
||||||
*/
|
*/
|
||||||
public static function TRUE() {
|
public static function TRUE()
|
||||||
return TRUE;
|
{
|
||||||
} // function TRUE()
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -74,9 +66,10 @@ class PHPExcel_Calculation_Logical {
|
||||||
* @category Logical Functions
|
* @category Logical Functions
|
||||||
* @return boolean False
|
* @return boolean False
|
||||||
*/
|
*/
|
||||||
public static function FALSE() {
|
public static function FALSE()
|
||||||
return FALSE;
|
{
|
||||||
} // function FALSE()
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -100,9 +93,10 @@ class PHPExcel_Calculation_Logical {
|
||||||
* @param mixed $arg,... Data values
|
* @param mixed $arg,... Data values
|
||||||
* @return boolean The logical AND of the arguments.
|
* @return boolean The logical AND of the arguments.
|
||||||
*/
|
*/
|
||||||
public static function LOGICAL_AND() {
|
public static function LOGICAL_AND()
|
||||||
|
{
|
||||||
// Return value
|
// Return value
|
||||||
$returnValue = TRUE;
|
$returnValue = true;
|
||||||
|
|
||||||
// Loop through the arguments
|
// Loop through the arguments
|
||||||
$aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
|
$aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
|
||||||
|
@ -116,9 +110,9 @@ class PHPExcel_Calculation_Logical {
|
||||||
} elseif (is_string($arg)) {
|
} elseif (is_string($arg)) {
|
||||||
$arg = strtoupper($arg);
|
$arg = strtoupper($arg);
|
||||||
if (($arg == 'TRUE') || ($arg == PHPExcel_Calculation::getTRUE())) {
|
if (($arg == 'TRUE') || ($arg == PHPExcel_Calculation::getTRUE())) {
|
||||||
$arg = TRUE;
|
$arg = true;
|
||||||
} elseif (($arg == 'FALSE') || ($arg == PHPExcel_Calculation::getFALSE())) {
|
} elseif (($arg == 'FALSE') || ($arg == PHPExcel_Calculation::getFALSE())) {
|
||||||
$arg = FALSE;
|
$arg = false;
|
||||||
} else {
|
} else {
|
||||||
return PHPExcel_Calculation_Functions::VALUE();
|
return PHPExcel_Calculation_Functions::VALUE();
|
||||||
}
|
}
|
||||||
|
@ -131,7 +125,7 @@ class PHPExcel_Calculation_Logical {
|
||||||
return PHPExcel_Calculation_Functions::VALUE();
|
return PHPExcel_Calculation_Functions::VALUE();
|
||||||
}
|
}
|
||||||
return $returnValue;
|
return $returnValue;
|
||||||
} // function LOGICAL_AND()
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -155,9 +149,10 @@ class PHPExcel_Calculation_Logical {
|
||||||
* @param mixed $arg,... Data values
|
* @param mixed $arg,... Data values
|
||||||
* @return boolean The logical OR of the arguments.
|
* @return boolean The logical OR of the arguments.
|
||||||
*/
|
*/
|
||||||
public static function LOGICAL_OR() {
|
public static function LOGICAL_OR()
|
||||||
|
{
|
||||||
// Return value
|
// Return value
|
||||||
$returnValue = FALSE;
|
$returnValue = false;
|
||||||
|
|
||||||
// Loop through the arguments
|
// Loop through the arguments
|
||||||
$aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
|
$aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
|
||||||
|
@ -171,9 +166,9 @@ class PHPExcel_Calculation_Logical {
|
||||||
} elseif (is_string($arg)) {
|
} elseif (is_string($arg)) {
|
||||||
$arg = strtoupper($arg);
|
$arg = strtoupper($arg);
|
||||||
if (($arg == 'TRUE') || ($arg == PHPExcel_Calculation::getTRUE())) {
|
if (($arg == 'TRUE') || ($arg == PHPExcel_Calculation::getTRUE())) {
|
||||||
$arg = TRUE;
|
$arg = true;
|
||||||
} elseif (($arg == 'FALSE') || ($arg == PHPExcel_Calculation::getFALSE())) {
|
} elseif (($arg == 'FALSE') || ($arg == PHPExcel_Calculation::getFALSE())) {
|
||||||
$arg = FALSE;
|
$arg = false;
|
||||||
} else {
|
} else {
|
||||||
return PHPExcel_Calculation_Functions::VALUE();
|
return PHPExcel_Calculation_Functions::VALUE();
|
||||||
}
|
}
|
||||||
|
@ -186,7 +181,7 @@ class PHPExcel_Calculation_Logical {
|
||||||
return PHPExcel_Calculation_Functions::VALUE();
|
return PHPExcel_Calculation_Functions::VALUE();
|
||||||
}
|
}
|
||||||
return $returnValue;
|
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
|
* @param mixed $logical A value or expression that can be evaluated to TRUE or FALSE
|
||||||
* @return boolean The boolean inverse of the argument.
|
* @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);
|
$logical = PHPExcel_Calculation_Functions::flattenSingleValue($logical);
|
||||||
if (is_string($logical)) {
|
if (is_string($logical)) {
|
||||||
$logical = strtoupper($logical);
|
$logical = strtoupper($logical);
|
||||||
if (($logical == 'TRUE') || ($logical == PHPExcel_Calculation::getTRUE())) {
|
if (($logical == 'TRUE') || ($logical == PHPExcel_Calculation::getTRUE())) {
|
||||||
return FALSE;
|
return false;
|
||||||
} elseif (($logical == 'FALSE') || ($logical == PHPExcel_Calculation::getFALSE())) {
|
} elseif (($logical == 'FALSE') || ($logical == PHPExcel_Calculation::getFALSE())) {
|
||||||
return TRUE;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return PHPExcel_Calculation_Functions::VALUE();
|
return PHPExcel_Calculation_Functions::VALUE();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return !$logical;
|
return !$logical;
|
||||||
} // function NOT()
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* STATEMENT_IF
|
* STATEMENT_IF
|
||||||
|
@ -257,13 +253,14 @@ class PHPExcel_Calculation_Logical {
|
||||||
* @param mixed $returnIfFalse Optional value to return when condition is false
|
* @param mixed $returnIfFalse Optional value to return when condition is false
|
||||||
* @return mixed The value of returnIfTrue or returnIfFalse determined by condition
|
* @return mixed The value of returnIfTrue or returnIfFalse determined by condition
|
||||||
*/
|
*/
|
||||||
public static function STATEMENT_IF($condition = TRUE, $returnIfTrue = 0, $returnIfFalse = FALSE) {
|
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);
|
$condition = (is_null($condition)) ? true : (boolean) PHPExcel_Calculation_Functions::flattenSingleValue($condition);
|
||||||
$returnIfFalse = (is_null($returnIfFalse)) ? FALSE : PHPExcel_Calculation_Functions::flattenSingleValue($returnIfFalse);
|
$returnIfTrue = (is_null($returnIfTrue)) ? 0 : PHPExcel_Calculation_Functions::flattenSingleValue($returnIfTrue);
|
||||||
|
$returnIfFalse = (is_null($returnIfFalse)) ? false : PHPExcel_Calculation_Functions::flattenSingleValue($returnIfFalse);
|
||||||
|
|
||||||
return ($condition) ? $returnIfTrue : $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
|
* @param mixed $errorpart Value to return when testValue is an error condition
|
||||||
* @return mixed The value of errorpart or testValue determined by 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);
|
$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);
|
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
|
* @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
|
* @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 === '') {
|
if (is_null($cellAddress) || $cellAddress === '') {
|
||||||
return 1;
|
return 1;
|
||||||
} elseif (!is_array($cellAddress)) {
|
} elseif (!is_array($cellAddress)) {
|
||||||
return PHPExcel_Calculation_Functions::VALUE();
|
return PHPExcel_Calculation_Functions::VALUE();
|
||||||
}
|
}
|
||||||
|
|
||||||
$x = array_keys($cellAddress);
|
reset($cellAddress);
|
||||||
$x = array_shift($x);
|
$isMatrix = (is_numeric(key($cellAddress)));
|
||||||
$isMatrix = (is_numeric($x));
|
|
||||||
list($columns,$rows) = PHPExcel_Calculation::_getMatrixDimensions($cellAddress);
|
list($columns,$rows) = PHPExcel_Calculation::_getMatrixDimensions($cellAddress);
|
||||||
|
|
||||||
if ($isMatrix) {
|
if ($isMatrix) {
|
||||||
|
@ -231,8 +230,8 @@ class PHPExcel_Calculation_LookupRef {
|
||||||
return PHPExcel_Calculation_Functions::VALUE();
|
return PHPExcel_Calculation_Functions::VALUE();
|
||||||
}
|
}
|
||||||
|
|
||||||
$i = array_keys($cellAddress);
|
reset($cellAddress);
|
||||||
$isMatrix = (is_numeric(array_shift($i)));
|
$isMatrix = (is_numeric(key($cellAddress)));
|
||||||
list($columns,$rows) = PHPExcel_Calculation::_getMatrixDimensions($cellAddress);
|
list($columns,$rows) = PHPExcel_Calculation::_getMatrixDimensions($cellAddress);
|
||||||
|
|
||||||
if ($isMatrix) {
|
if ($isMatrix) {
|
||||||
|
@ -672,8 +671,8 @@ class PHPExcel_Calculation_LookupRef {
|
||||||
|
|
||||||
|
|
||||||
private static function _vlookupSort($a,$b) {
|
private static function _vlookupSort($a,$b) {
|
||||||
$f = array_keys($a);
|
reset($a);
|
||||||
$firstColumn = array_shift($f);
|
$firstColumn = key($a);
|
||||||
if (strtolower($a[$firstColumn]) == strtolower($b[$firstColumn])) {
|
if (strtolower($a[$firstColumn]) == strtolower($b[$firstColumn])) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2526,7 +2526,7 @@ class PHPExcel_Calculation_Statistical {
|
||||||
}
|
}
|
||||||
if ((is_numeric($cumulative)) || (is_bool($cumulative))) {
|
if ((is_numeric($cumulative)) || (is_bool($cumulative))) {
|
||||||
if ($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 {
|
} else {
|
||||||
return (1 / (SQRT2PI * $stdDev)) * exp(0 - (pow($value - $mean,2) / (2 * ($stdDev * $stdDev))));
|
return (1 / (SQRT2PI * $stdDev)) * exp(0 - (pow($value - $mean,2) / (2 * ($stdDev * $stdDev))));
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,4 +127,4 @@ foreach ($aTests as $sTest) {
|
||||||
echo shell_exec('php ' . $sTest);
|
echo shell_exec('php ' . $sTest);
|
||||||
echo "\r\n";
|
echo "\r\n";
|
||||||
echo "\r\n";
|
echo "\r\n";
|
||||||
}
|
}
|
Loading…
Reference in New Issue