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