More namespacing work and soem initial rework for unit tests to handle new folder structure
This commit is contained in:
parent
550907fc77
commit
538fe93105
|
@ -530,16 +530,16 @@ class DateTime
|
|||
$testVal3 = strftime('%Y');
|
||||
}
|
||||
} else {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
} else {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
$PHPDateArray = date_parse($testVal1.'-'.$testVal2.'-'.$testVal3);
|
||||
if (($PHPDateArray === false) || ($PHPDateArray['error_count'] > 0)) {
|
||||
$PHPDateArray = date_parse($testVal2.'-'.$testVal1.'-'.$testVal3);
|
||||
if (($PHPDateArray === false) || ($PHPDateArray['error_count'] > 0)) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -550,7 +550,7 @@ class DateTime
|
|||
$PHPDateArray['year'] = strftime('%Y');
|
||||
}
|
||||
if ($PHPDateArray['year'] < 1900) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
if ($PHPDateArray['month'] == '') {
|
||||
$PHPDateArray['month'] = strftime('%m');
|
||||
|
@ -569,16 +569,16 @@ class DateTime
|
|||
)
|
||||
);
|
||||
|
||||
switch (PHPExcel_Calculation_Functions::getReturnDateType()) {
|
||||
case PHPExcel_Calculation_Functions::RETURNDATE_EXCEL:
|
||||
switch (Functions::getReturnDateType()) {
|
||||
case Functions::RETURNDATE_EXCEL:
|
||||
return (float) $excelDateValue;
|
||||
case PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC:
|
||||
case Functions::RETURNDATE_PHP_NUMERIC:
|
||||
return (integer) PHPExcel_Shared_Date::ExcelToPHP($excelDateValue);
|
||||
case PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT:
|
||||
case Functions::RETURNDATE_PHP_OBJECT:
|
||||
return new DateTime($PHPDateArray['year'].'-'.$PHPDateArray['month'].'-'.$PHPDateArray['day'].' 00:00:00');
|
||||
}
|
||||
}
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
|
||||
|
@ -606,12 +606,12 @@ class DateTime
|
|||
*/
|
||||
public static function TIMEVALUE($timeValue)
|
||||
{
|
||||
$timeValue = trim(PHPExcel_Calculation_Functions::flattenSingleValue($timeValue), '"');
|
||||
$timeValue = trim(Functions::flattenSingleValue($timeValue), '"');
|
||||
$timeValue = str_replace(array('/', '.'), array('-', '-'), $timeValue);
|
||||
|
||||
$PHPDateArray = date_parse($timeValue);
|
||||
if (($PHPDateArray !== false) && ($PHPDateArray['error_count'] == 0)) {
|
||||
if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE) {
|
||||
if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_OPENOFFICE) {
|
||||
$excelDateValue = PHPExcel_Shared_Date::FormattedPHPToExcel(
|
||||
$PHPDateArray['year'],
|
||||
$PHPDateArray['month'],
|
||||
|
@ -624,16 +624,16 @@ class DateTime
|
|||
$excelDateValue = PHPExcel_Shared_Date::FormattedPHPToExcel(1900, 1, 1, $PHPDateArray['hour'], $PHPDateArray['minute'], $PHPDateArray['second']) - 1;
|
||||
}
|
||||
|
||||
switch (PHPExcel_Calculation_Functions::getReturnDateType()) {
|
||||
case PHPExcel_Calculation_Functions::RETURNDATE_EXCEL:
|
||||
switch (Functions::getReturnDateType()) {
|
||||
case Functions::RETURNDATE_EXCEL:
|
||||
return (float) $excelDateValue;
|
||||
case PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC:
|
||||
case Functions::RETURNDATE_PHP_NUMERIC:
|
||||
return (integer) $phpDateValue = PHPExcel_Shared_Date::ExcelToPHP($excelDateValue+25569) - 3600;
|
||||
case PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT:
|
||||
case Functions::RETURNDATE_PHP_OBJECT:
|
||||
return new DateTime('1900-01-01 '.$PHPDateArray['hour'].':'.$PHPDateArray['minute'].':'.$PHPDateArray['second']);
|
||||
}
|
||||
}
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
|
||||
|
@ -649,20 +649,20 @@ class DateTime
|
|||
*/
|
||||
public static function DATEDIF($startDate = 0, $endDate = 0, $unit = 'D')
|
||||
{
|
||||
$startDate = PHPExcel_Calculation_Functions::flattenSingleValue($startDate);
|
||||
$endDate = PHPExcel_Calculation_Functions::flattenSingleValue($endDate);
|
||||
$unit = strtoupper(PHPExcel_Calculation_Functions::flattenSingleValue($unit));
|
||||
$startDate = Functions::flattenSingleValue($startDate);
|
||||
$endDate = Functions::flattenSingleValue($endDate);
|
||||
$unit = strtoupper(Functions::flattenSingleValue($unit));
|
||||
|
||||
if (is_string($startDate = self::getDateValue($startDate))) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
if (is_string($endDate = self::getDateValue($endDate))) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
// Validate parameters
|
||||
if ($startDate >= $endDate) {
|
||||
return PHPExcel_Calculation_Functions::NaN();
|
||||
return Functions::NaN();
|
||||
}
|
||||
|
||||
// Execute function
|
||||
|
@ -678,7 +678,7 @@ class DateTime
|
|||
$endMonths = $PHPEndDateObject->format('n');
|
||||
$endYears = $PHPEndDateObject->format('Y');
|
||||
|
||||
$retVal = PHPExcel_Calculation_Functions::NaN();
|
||||
$retVal = Functions::NaN();
|
||||
switch ($unit) {
|
||||
case 'D':
|
||||
$retVal = intval($difference);
|
||||
|
@ -735,7 +735,7 @@ class DateTime
|
|||
}
|
||||
break;
|
||||
default:
|
||||
$retVal = PHPExcel_Calculation_Functions::NaN();
|
||||
$retVal = Functions::NaN();
|
||||
}
|
||||
return $retVal;
|
||||
}
|
||||
|
@ -772,18 +772,18 @@ class DateTime
|
|||
*/
|
||||
public static function DAYS360($startDate = 0, $endDate = 0, $method = false)
|
||||
{
|
||||
$startDate = PHPExcel_Calculation_Functions::flattenSingleValue($startDate);
|
||||
$endDate = PHPExcel_Calculation_Functions::flattenSingleValue($endDate);
|
||||
$startDate = Functions::flattenSingleValue($startDate);
|
||||
$endDate = Functions::flattenSingleValue($endDate);
|
||||
|
||||
if (is_string($startDate = self::getDateValue($startDate))) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
if (is_string($endDate = self::getDateValue($endDate))) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
if (!is_bool($method)) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
// Execute function
|
||||
|
@ -828,15 +828,15 @@ class DateTime
|
|||
*/
|
||||
public static function YEARFRAC($startDate = 0, $endDate = 0, $method = 0)
|
||||
{
|
||||
$startDate = PHPExcel_Calculation_Functions::flattenSingleValue($startDate);
|
||||
$endDate = PHPExcel_Calculation_Functions::flattenSingleValue($endDate);
|
||||
$method = PHPExcel_Calculation_Functions::flattenSingleValue($method);
|
||||
$startDate = Functions::flattenSingleValue($startDate);
|
||||
$endDate = Functions::flattenSingleValue($endDate);
|
||||
$method = Functions::flattenSingleValue($method);
|
||||
|
||||
if (is_string($startDate = self::getDateValue($startDate))) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
if (is_string($endDate = self::getDateValue($endDate))) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
if (((is_numeric($method)) && (!is_string($method))) || ($method == '')) {
|
||||
|
@ -895,7 +895,7 @@ class DateTime
|
|||
return self::DAYS360($startDate, $endDate, true) / 360;
|
||||
}
|
||||
}
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
|
||||
|
@ -925,20 +925,20 @@ class DateTime
|
|||
public static function NETWORKDAYS($startDate, $endDate)
|
||||
{
|
||||
// Retrieve the mandatory start and end date that are referenced in the function definition
|
||||
$startDate = PHPExcel_Calculation_Functions::flattenSingleValue($startDate);
|
||||
$endDate = PHPExcel_Calculation_Functions::flattenSingleValue($endDate);
|
||||
$startDate = Functions::flattenSingleValue($startDate);
|
||||
$endDate = Functions::flattenSingleValue($endDate);
|
||||
// Flush the mandatory start and end date that are referenced in the function definition, and get the optional days
|
||||
$dateArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
|
||||
$dateArgs = Functions::flattenArray(func_get_args());
|
||||
array_shift($dateArgs);
|
||||
array_shift($dateArgs);
|
||||
|
||||
// Validate the start and end dates
|
||||
if (is_string($startDate = $sDate = self::getDateValue($startDate))) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
$startDate = (float) floor($startDate);
|
||||
if (is_string($endDate = $eDate = self::getDateValue($endDate))) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
$endDate = (float) floor($endDate);
|
||||
|
||||
|
@ -967,7 +967,7 @@ class DateTime
|
|||
$holidayCountedArray = array();
|
||||
foreach ($dateArgs as $holidayDate) {
|
||||
if (is_string($holidayDate = self::getDateValue($holidayDate))) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
if (($holidayDate >= $startDate) && ($holidayDate <= $endDate)) {
|
||||
if ((self::DAYOFWEEK($holidayDate, 2) < 6) && (!in_array($holidayDate, $holidayCountedArray))) {
|
||||
|
@ -1012,15 +1012,15 @@ class DateTime
|
|||
public static function WORKDAY($startDate, $endDays)
|
||||
{
|
||||
// Retrieve the mandatory start date and days that are referenced in the function definition
|
||||
$startDate = PHPExcel_Calculation_Functions::flattenSingleValue($startDate);
|
||||
$endDays = PHPExcel_Calculation_Functions::flattenSingleValue($endDays);
|
||||
$startDate = Functions::flattenSingleValue($startDate);
|
||||
$endDays = Functions::flattenSingleValue($endDays);
|
||||
// Flush the mandatory start date and days that are referenced in the function definition, and get the optional days
|
||||
$dateArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
|
||||
$dateArgs = Functions::flattenArray(func_get_args());
|
||||
array_shift($dateArgs);
|
||||
array_shift($dateArgs);
|
||||
|
||||
if ((is_string($startDate = self::getDateValue($startDate))) || (!is_numeric($endDays))) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
$startDate = (float) floor($startDate);
|
||||
$endDays = (int) floor($endDays);
|
||||
|
@ -1054,7 +1054,7 @@ class DateTime
|
|||
foreach ($dateArgs as $holidayDate) {
|
||||
if (($holidayDate !== null) && (trim($holidayDate) > '')) {
|
||||
if (is_string($holidayDate = self::getDateValue($holidayDate))) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
if (self::DAYOFWEEK($holidayDate, 3) < 5) {
|
||||
$holidayDates[] = $holidayDate;
|
||||
|
@ -1090,12 +1090,12 @@ class DateTime
|
|||
}
|
||||
}
|
||||
|
||||
switch (PHPExcel_Calculation_Functions::getReturnDateType()) {
|
||||
case PHPExcel_Calculation_Functions::RETURNDATE_EXCEL:
|
||||
switch (Functions::getReturnDateType()) {
|
||||
case Functions::RETURNDATE_EXCEL:
|
||||
return (float) $endDate;
|
||||
case PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC:
|
||||
case Functions::RETURNDATE_PHP_NUMERIC:
|
||||
return (integer) PHPExcel_Shared_Date::ExcelToPHP($endDate);
|
||||
case PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT:
|
||||
case Functions::RETURNDATE_PHP_OBJECT:
|
||||
return PHPExcel_Shared_Date::ExcelToPHPObject($endDate);
|
||||
}
|
||||
}
|
||||
|
@ -1116,16 +1116,16 @@ class DateTime
|
|||
*/
|
||||
public static function DAYOFMONTH($dateValue = 1)
|
||||
{
|
||||
$dateValue = PHPExcel_Calculation_Functions::flattenSingleValue($dateValue);
|
||||
$dateValue = Functions::flattenSingleValue($dateValue);
|
||||
|
||||
if ($dateValue === null) {
|
||||
$dateValue = 1;
|
||||
} elseif (is_string($dateValue = self::getDateValue($dateValue))) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
} elseif ($dateValue == 0.0) {
|
||||
return 0;
|
||||
} elseif ($dateValue < 0.0) {
|
||||
return PHPExcel_Calculation_Functions::NaN();
|
||||
return Functions::NaN();
|
||||
}
|
||||
|
||||
// Execute function
|
||||
|
@ -1154,22 +1154,22 @@ class DateTime
|
|||
*/
|
||||
public static function DAYOFWEEK($dateValue = 1, $style = 1)
|
||||
{
|
||||
$dateValue = PHPExcel_Calculation_Functions::flattenSingleValue($dateValue);
|
||||
$style = PHPExcel_Calculation_Functions::flattenSingleValue($style);
|
||||
$dateValue = Functions::flattenSingleValue($dateValue);
|
||||
$style = Functions::flattenSingleValue($style);
|
||||
|
||||
if (!is_numeric($style)) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
} elseif (($style < 1) || ($style > 3)) {
|
||||
return PHPExcel_Calculation_Functions::NaN();
|
||||
return Functions::NaN();
|
||||
}
|
||||
$style = floor($style);
|
||||
|
||||
if ($dateValue === null) {
|
||||
$dateValue = 1;
|
||||
} elseif (is_string($dateValue = self::getDateValue($dateValue))) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
} elseif ($dateValue < 0.0) {
|
||||
return PHPExcel_Calculation_Functions::NaN();
|
||||
return Functions::NaN();
|
||||
}
|
||||
|
||||
// Execute function
|
||||
|
@ -1194,7 +1194,7 @@ class DateTime
|
|||
--$DoW;
|
||||
break;
|
||||
}
|
||||
if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_EXCEL) {
|
||||
if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_EXCEL) {
|
||||
// Test for Excel's 1900 leap year, and introduce the error as required
|
||||
if (($PHPDateObject->format('Y') == 1900) && ($PHPDateObject->format('n') <= 2)) {
|
||||
--$DoW;
|
||||
|
@ -1230,22 +1230,22 @@ class DateTime
|
|||
*/
|
||||
public static function WEEKOFYEAR($dateValue = 1, $method = 1)
|
||||
{
|
||||
$dateValue = PHPExcel_Calculation_Functions::flattenSingleValue($dateValue);
|
||||
$method = PHPExcel_Calculation_Functions::flattenSingleValue($method);
|
||||
$dateValue = Functions::flattenSingleValue($dateValue);
|
||||
$method = Functions::flattenSingleValue($method);
|
||||
|
||||
if (!is_numeric($method)) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
} elseif (($method < 1) || ($method > 2)) {
|
||||
return PHPExcel_Calculation_Functions::NaN();
|
||||
return Functions::NaN();
|
||||
}
|
||||
$method = floor($method);
|
||||
|
||||
if ($dateValue === null) {
|
||||
$dateValue = 1;
|
||||
} elseif (is_string($dateValue = self::getDateValue($dateValue))) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
} elseif ($dateValue < 0.0) {
|
||||
return PHPExcel_Calculation_Functions::NaN();
|
||||
return Functions::NaN();
|
||||
}
|
||||
|
||||
// Execute function
|
||||
|
@ -1277,14 +1277,14 @@ class DateTime
|
|||
*/
|
||||
public static function MONTHOFYEAR($dateValue = 1)
|
||||
{
|
||||
$dateValue = PHPExcel_Calculation_Functions::flattenSingleValue($dateValue);
|
||||
$dateValue = Functions::flattenSingleValue($dateValue);
|
||||
|
||||
if ($dateValue === null) {
|
||||
$dateValue = 1;
|
||||
} elseif (is_string($dateValue = self::getDateValue($dateValue))) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
} elseif ($dateValue < 0.0) {
|
||||
return PHPExcel_Calculation_Functions::NaN();
|
||||
return Functions::NaN();
|
||||
}
|
||||
|
||||
// Execute function
|
||||
|
@ -1309,14 +1309,14 @@ class DateTime
|
|||
*/
|
||||
public static function YEAR($dateValue = 1)
|
||||
{
|
||||
$dateValue = PHPExcel_Calculation_Functions::flattenSingleValue($dateValue);
|
||||
$dateValue = Functions::flattenSingleValue($dateValue);
|
||||
|
||||
if ($dateValue === null) {
|
||||
$dateValue = 1;
|
||||
} elseif (is_string($dateValue = self::getDateValue($dateValue))) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
} elseif ($dateValue < 0.0) {
|
||||
return PHPExcel_Calculation_Functions::NaN();
|
||||
return Functions::NaN();
|
||||
}
|
||||
|
||||
// Execute function
|
||||
|
@ -1341,25 +1341,25 @@ class DateTime
|
|||
*/
|
||||
public static function HOUROFDAY($timeValue = 0)
|
||||
{
|
||||
$timeValue = PHPExcel_Calculation_Functions::flattenSingleValue($timeValue);
|
||||
$timeValue = Functions::flattenSingleValue($timeValue);
|
||||
|
||||
if (!is_numeric($timeValue)) {
|
||||
if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_GNUMERIC) {
|
||||
if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_GNUMERIC) {
|
||||
$testVal = strtok($timeValue, '/-: ');
|
||||
if (strlen($testVal) < strlen($timeValue)) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
}
|
||||
$timeValue = self::getTimeValue($timeValue);
|
||||
if (is_string($timeValue)) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
}
|
||||
// Execute function
|
||||
if ($timeValue >= 1) {
|
||||
$timeValue = fmod($timeValue, 1);
|
||||
} elseif ($timeValue < 0.0) {
|
||||
return PHPExcel_Calculation_Functions::NaN();
|
||||
return Functions::NaN();
|
||||
}
|
||||
$timeValue = PHPExcel_Shared_Date::ExcelToPHP($timeValue);
|
||||
|
||||
|
@ -1382,25 +1382,25 @@ class DateTime
|
|||
*/
|
||||
public static function MINUTEOFHOUR($timeValue = 0)
|
||||
{
|
||||
$timeValue = $timeTester = PHPExcel_Calculation_Functions::flattenSingleValue($timeValue);
|
||||
$timeValue = $timeTester = Functions::flattenSingleValue($timeValue);
|
||||
|
||||
if (!is_numeric($timeValue)) {
|
||||
if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_GNUMERIC) {
|
||||
if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_GNUMERIC) {
|
||||
$testVal = strtok($timeValue, '/-: ');
|
||||
if (strlen($testVal) < strlen($timeValue)) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
}
|
||||
$timeValue = self::getTimeValue($timeValue);
|
||||
if (is_string($timeValue)) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
}
|
||||
// Execute function
|
||||
if ($timeValue >= 1) {
|
||||
$timeValue = fmod($timeValue, 1);
|
||||
} elseif ($timeValue < 0.0) {
|
||||
return PHPExcel_Calculation_Functions::NaN();
|
||||
return Functions::NaN();
|
||||
}
|
||||
$timeValue = PHPExcel_Shared_Date::ExcelToPHP($timeValue);
|
||||
|
||||
|
@ -1423,25 +1423,25 @@ class DateTime
|
|||
*/
|
||||
public static function SECONDOFMINUTE($timeValue = 0)
|
||||
{
|
||||
$timeValue = PHPExcel_Calculation_Functions::flattenSingleValue($timeValue);
|
||||
$timeValue = Functions::flattenSingleValue($timeValue);
|
||||
|
||||
if (!is_numeric($timeValue)) {
|
||||
if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_GNUMERIC) {
|
||||
if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_GNUMERIC) {
|
||||
$testVal = strtok($timeValue, '/-: ');
|
||||
if (strlen($testVal) < strlen($timeValue)) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
}
|
||||
$timeValue = self::getTimeValue($timeValue);
|
||||
if (is_string($timeValue)) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
}
|
||||
// Execute function
|
||||
if ($timeValue >= 1) {
|
||||
$timeValue = fmod($timeValue, 1);
|
||||
} elseif ($timeValue < 0.0) {
|
||||
return PHPExcel_Calculation_Functions::NaN();
|
||||
return Functions::NaN();
|
||||
}
|
||||
$timeValue = PHPExcel_Shared_Date::ExcelToPHP($timeValue);
|
||||
|
||||
|
@ -1470,27 +1470,27 @@ class DateTime
|
|||
*/
|
||||
public static function EDATE($dateValue = 1, $adjustmentMonths = 0)
|
||||
{
|
||||
$dateValue = PHPExcel_Calculation_Functions::flattenSingleValue($dateValue);
|
||||
$adjustmentMonths = PHPExcel_Calculation_Functions::flattenSingleValue($adjustmentMonths);
|
||||
$dateValue = Functions::flattenSingleValue($dateValue);
|
||||
$adjustmentMonths = Functions::flattenSingleValue($adjustmentMonths);
|
||||
|
||||
if (!is_numeric($adjustmentMonths)) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
$adjustmentMonths = floor($adjustmentMonths);
|
||||
|
||||
if (is_string($dateValue = self::getDateValue($dateValue))) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
// Execute function
|
||||
$PHPDateObject = self::adjustDateByMonths($dateValue, $adjustmentMonths);
|
||||
|
||||
switch (PHPExcel_Calculation_Functions::getReturnDateType()) {
|
||||
case PHPExcel_Calculation_Functions::RETURNDATE_EXCEL:
|
||||
switch (Functions::getReturnDateType()) {
|
||||
case Functions::RETURNDATE_EXCEL:
|
||||
return (float) PHPExcel_Shared_Date::PHPToExcel($PHPDateObject);
|
||||
case PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC:
|
||||
case Functions::RETURNDATE_PHP_NUMERIC:
|
||||
return (integer) PHPExcel_Shared_Date::ExcelToPHP(PHPExcel_Shared_Date::PHPToExcel($PHPDateObject));
|
||||
case PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT:
|
||||
case Functions::RETURNDATE_PHP_OBJECT:
|
||||
return $PHPDateObject;
|
||||
}
|
||||
}
|
||||
|
@ -1516,16 +1516,16 @@ class DateTime
|
|||
*/
|
||||
public static function EOMONTH($dateValue = 1, $adjustmentMonths = 0)
|
||||
{
|
||||
$dateValue = PHPExcel_Calculation_Functions::flattenSingleValue($dateValue);
|
||||
$adjustmentMonths = PHPExcel_Calculation_Functions::flattenSingleValue($adjustmentMonths);
|
||||
$dateValue = Functions::flattenSingleValue($dateValue);
|
||||
$adjustmentMonths = Functions::flattenSingleValue($adjustmentMonths);
|
||||
|
||||
if (!is_numeric($adjustmentMonths)) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
$adjustmentMonths = floor($adjustmentMonths);
|
||||
|
||||
if (is_string($dateValue = self::getDateValue($dateValue))) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
// Execute function
|
||||
|
@ -1534,12 +1534,12 @@ class DateTime
|
|||
$adjustDaysString = '-' . $adjustDays . ' days';
|
||||
$PHPDateObject->modify($adjustDaysString);
|
||||
|
||||
switch (PHPExcel_Calculation_Functions::getReturnDateType()) {
|
||||
case PHPExcel_Calculation_Functions::RETURNDATE_EXCEL:
|
||||
switch (Functions::getReturnDateType()) {
|
||||
case Functions::RETURNDATE_EXCEL:
|
||||
return (float) PHPExcel_Shared_Date::PHPToExcel($PHPDateObject);
|
||||
case PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC:
|
||||
case Functions::RETURNDATE_PHP_NUMERIC:
|
||||
return (integer) PHPExcel_Shared_Date::ExcelToPHP(PHPExcel_Shared_Date::PHPToExcel($PHPDateObject));
|
||||
case PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT:
|
||||
case Functions::RETURNDATE_PHP_OBJECT:
|
||||
return $PHPDateObject;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -830,7 +830,7 @@ class Engineering
|
|||
if (strlen($xVal) <= $places) {
|
||||
return substr(str_pad($xVal, $places, '0', STR_PAD_LEFT), -10);
|
||||
} else {
|
||||
return PHPExcel_Calculation_Functions::NaN();
|
||||
return Functions::NaN();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -859,17 +859,17 @@ class Engineering
|
|||
*/
|
||||
public static function BESSELI($x, $ord)
|
||||
{
|
||||
$x = (is_null($x)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($x);
|
||||
$ord = (is_null($ord)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($ord);
|
||||
$x = (is_null($x)) ? 0.0 : Functions::flattenSingleValue($x);
|
||||
$ord = (is_null($ord)) ? 0.0 : Functions::flattenSingleValue($ord);
|
||||
|
||||
if ((is_numeric($x)) && (is_numeric($ord))) {
|
||||
$ord = floor($ord);
|
||||
if ($ord < 0) {
|
||||
return PHPExcel_Calculation_Functions::NaN();
|
||||
return Functions::NaN();
|
||||
}
|
||||
|
||||
if (abs($x) <= 30) {
|
||||
$fResult = $fTerm = pow($x / 2, $ord) / PHPExcel_Calculation_MathTrig::FACT($ord);
|
||||
$fResult = $fTerm = pow($x / 2, $ord) / MathTrig::FACT($ord);
|
||||
$ordK = 1;
|
||||
$fSqrX = ($x * $x) / 4;
|
||||
do {
|
||||
|
@ -886,9 +886,9 @@ class Engineering
|
|||
$fResult = -$fResult;
|
||||
}
|
||||
}
|
||||
return (is_nan($fResult)) ? PHPExcel_Calculation_Functions::NaN() : $fResult;
|
||||
return (is_nan($fResult)) ? Functions::NaN() : $fResult;
|
||||
}
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
|
||||
|
@ -912,18 +912,18 @@ class Engineering
|
|||
*/
|
||||
public static function BESSELJ($x, $ord)
|
||||
{
|
||||
$x = (is_null($x)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($x);
|
||||
$ord = (is_null($ord)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($ord);
|
||||
$x = (is_null($x)) ? 0.0 : Functions::flattenSingleValue($x);
|
||||
$ord = (is_null($ord)) ? 0.0 : Functions::flattenSingleValue($ord);
|
||||
|
||||
if ((is_numeric($x)) && (is_numeric($ord))) {
|
||||
$ord = floor($ord);
|
||||
if ($ord < 0) {
|
||||
return PHPExcel_Calculation_Functions::NaN();
|
||||
return Functions::NaN();
|
||||
}
|
||||
|
||||
$fResult = 0;
|
||||
if (abs($x) <= 30) {
|
||||
$fResult = $fTerm = pow($x / 2, $ord) / PHPExcel_Calculation_MathTrig::FACT($ord);
|
||||
$fResult = $fTerm = pow($x / 2, $ord) / MathTrig::FACT($ord);
|
||||
$ordK = 1;
|
||||
$fSqrX = ($x * $x) / -4;
|
||||
do {
|
||||
|
@ -941,9 +941,9 @@ class Engineering
|
|||
$fResult = -$fResult;
|
||||
}
|
||||
}
|
||||
return (is_nan($fResult)) ? PHPExcel_Calculation_Functions::NaN() : $fResult;
|
||||
return (is_nan($fResult)) ? Functions::NaN() : $fResult;
|
||||
}
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
|
||||
|
@ -1004,12 +1004,12 @@ class Engineering
|
|||
*/
|
||||
public static function BESSELK($x, $ord)
|
||||
{
|
||||
$x = (is_null($x)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($x);
|
||||
$ord = (is_null($ord)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($ord);
|
||||
$x = (is_null($x)) ? 0.0 : Functions::flattenSingleValue($x);
|
||||
$ord = (is_null($ord)) ? 0.0 : Functions::flattenSingleValue($ord);
|
||||
|
||||
if ((is_numeric($x)) && (is_numeric($ord))) {
|
||||
if (($ord < 0) || ($x == 0.0)) {
|
||||
return PHPExcel_Calculation_Functions::NaN();
|
||||
return Functions::NaN();
|
||||
}
|
||||
|
||||
switch (floor($ord)) {
|
||||
|
@ -1027,9 +1027,9 @@ class Engineering
|
|||
$fBk = $fBkp;
|
||||
}
|
||||
}
|
||||
return (is_nan($fBk)) ? PHPExcel_Calculation_Functions::NaN() : $fBk;
|
||||
return (is_nan($fBk)) ? Functions::NaN() : $fBk;
|
||||
}
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
|
||||
|
@ -1088,12 +1088,12 @@ class Engineering
|
|||
*/
|
||||
public static function BESSELY($x, $ord)
|
||||
{
|
||||
$x = (is_null($x)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($x);
|
||||
$ord = (is_null($ord)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($ord);
|
||||
$x = (is_null($x)) ? 0.0 : Functions::flattenSingleValue($x);
|
||||
$ord = (is_null($ord)) ? 0.0 : Functions::flattenSingleValue($ord);
|
||||
|
||||
if ((is_numeric($x)) && (is_numeric($ord))) {
|
||||
if (($ord < 0) || ($x == 0.0)) {
|
||||
return PHPExcel_Calculation_Functions::NaN();
|
||||
return Functions::NaN();
|
||||
}
|
||||
|
||||
switch (floor($ord)) {
|
||||
|
@ -1111,9 +1111,9 @@ class Engineering
|
|||
$fBy = $fByp;
|
||||
}
|
||||
}
|
||||
return (is_nan($fBy)) ? PHPExcel_Calculation_Functions::NaN() : $fBy;
|
||||
return (is_nan($fBy)) ? Functions::NaN() : $fBy;
|
||||
}
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
|
||||
|
@ -1137,24 +1137,24 @@ class Engineering
|
|||
*/
|
||||
public static function BINTODEC($x)
|
||||
{
|
||||
$x = PHPExcel_Calculation_Functions::flattenSingleValue($x);
|
||||
$x = Functions::flattenSingleValue($x);
|
||||
|
||||
if (is_bool($x)) {
|
||||
if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE) {
|
||||
if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_OPENOFFICE) {
|
||||
$x = (int) $x;
|
||||
} else {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
}
|
||||
if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_GNUMERIC) {
|
||||
if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_GNUMERIC) {
|
||||
$x = floor($x);
|
||||
}
|
||||
$x = (string) $x;
|
||||
if (strlen($x) > preg_match_all('/[01]/', $x, $out)) {
|
||||
return PHPExcel_Calculation_Functions::NaN();
|
||||
return Functions::NaN();
|
||||
}
|
||||
if (strlen($x) > 10) {
|
||||
return PHPExcel_Calculation_Functions::NaN();
|
||||
return Functions::NaN();
|
||||
} elseif (strlen($x) == 10) {
|
||||
// Two's Complement
|
||||
$x = substr($x, -9);
|
||||
|
@ -1190,25 +1190,25 @@ class Engineering
|
|||
*/
|
||||
public static function BINTOHEX($x, $places = null)
|
||||
{
|
||||
$x = PHPExcel_Calculation_Functions::flattenSingleValue($x);
|
||||
$places = PHPExcel_Calculation_Functions::flattenSingleValue($places);
|
||||
$x = Functions::flattenSingleValue($x);
|
||||
$places = Functions::flattenSingleValue($places);
|
||||
|
||||
if (is_bool($x)) {
|
||||
if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE) {
|
||||
if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_OPENOFFICE) {
|
||||
$x = (int) $x;
|
||||
} else {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
}
|
||||
if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_GNUMERIC) {
|
||||
if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_GNUMERIC) {
|
||||
$x = floor($x);
|
||||
}
|
||||
$x = (string) $x;
|
||||
if (strlen($x) > preg_match_all('/[01]/', $x, $out)) {
|
||||
return PHPExcel_Calculation_Functions::NaN();
|
||||
return Functions::NaN();
|
||||
}
|
||||
if (strlen($x) > 10) {
|
||||
return PHPExcel_Calculation_Functions::NaN();
|
||||
return Functions::NaN();
|
||||
} elseif (strlen($x) == 10) {
|
||||
// Two's Complement
|
||||
return str_repeat('F', 8).substr(strtoupper(dechex(bindec(substr($x, -9)))), -2);
|
||||
|
@ -1245,25 +1245,25 @@ class Engineering
|
|||
*/
|
||||
public static function BINTOOCT($x, $places = null)
|
||||
{
|
||||
$x = PHPExcel_Calculation_Functions::flattenSingleValue($x);
|
||||
$places = PHPExcel_Calculation_Functions::flattenSingleValue($places);
|
||||
$x = Functions::flattenSingleValue($x);
|
||||
$places = Functions::flattenSingleValue($places);
|
||||
|
||||
if (is_bool($x)) {
|
||||
if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE) {
|
||||
if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_OPENOFFICE) {
|
||||
$x = (int) $x;
|
||||
} else {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
}
|
||||
if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_GNUMERIC) {
|
||||
if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_GNUMERIC) {
|
||||
$x = floor($x);
|
||||
}
|
||||
$x = (string) $x;
|
||||
if (strlen($x) > preg_match_all('/[01]/', $x, $out)) {
|
||||
return PHPExcel_Calculation_Functions::NaN();
|
||||
return Functions::NaN();
|
||||
}
|
||||
if (strlen($x) > 10) {
|
||||
return PHPExcel_Calculation_Functions::NaN();
|
||||
return Functions::NaN();
|
||||
} elseif (strlen($x) == 10) {
|
||||
// Two's Complement
|
||||
return str_repeat('7', 7).substr(strtoupper(decoct(bindec(substr($x, -9)))), -3);
|
||||
|
@ -1304,19 +1304,19 @@ class Engineering
|
|||
*/
|
||||
public static function DECTOBIN($x, $places = null)
|
||||
{
|
||||
$x = PHPExcel_Calculation_Functions::flattenSingleValue($x);
|
||||
$places = PHPExcel_Calculation_Functions::flattenSingleValue($places);
|
||||
$x = Functions::flattenSingleValue($x);
|
||||
$places = Functions::flattenSingleValue($places);
|
||||
|
||||
if (is_bool($x)) {
|
||||
if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE) {
|
||||
if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_OPENOFFICE) {
|
||||
$x = (int) $x;
|
||||
} else {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
}
|
||||
$x = (string) $x;
|
||||
if (strlen($x) > preg_match_all('/[-0123456789.]/', $x, $out)) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
$x = (string) floor($x);
|
||||
$r = decbin($x);
|
||||
|
@ -1324,7 +1324,7 @@ class Engineering
|
|||
// Two's Complement
|
||||
$r = substr($r, -10);
|
||||
} elseif (strlen($r) > 11) {
|
||||
return PHPExcel_Calculation_Functions::NaN();
|
||||
return Functions::NaN();
|
||||
}
|
||||
|
||||
return self::nbrConversionFormat($r, $places);
|
||||
|
@ -1361,19 +1361,19 @@ class Engineering
|
|||
*/
|
||||
public static function DECTOHEX($x, $places = null)
|
||||
{
|
||||
$x = PHPExcel_Calculation_Functions::flattenSingleValue($x);
|
||||
$places = PHPExcel_Calculation_Functions::flattenSingleValue($places);
|
||||
$x = Functions::flattenSingleValue($x);
|
||||
$places = Functions::flattenSingleValue($places);
|
||||
|
||||
if (is_bool($x)) {
|
||||
if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE) {
|
||||
if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_OPENOFFICE) {
|
||||
$x = (int) $x;
|
||||
} else {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
}
|
||||
$x = (string) $x;
|
||||
if (strlen($x) > preg_match_all('/[-0123456789.]/', $x, $out)) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
$x = (string) floor($x);
|
||||
$r = strtoupper(dechex($x));
|
||||
|
@ -1416,19 +1416,19 @@ class Engineering
|
|||
*/
|
||||
public static function DECTOOCT($x, $places = null)
|
||||
{
|
||||
$x = PHPExcel_Calculation_Functions::flattenSingleValue($x);
|
||||
$places = PHPExcel_Calculation_Functions::flattenSingleValue($places);
|
||||
$x = Functions::flattenSingleValue($x);
|
||||
$places = Functions::flattenSingleValue($places);
|
||||
|
||||
if (is_bool($x)) {
|
||||
if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE) {
|
||||
if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_OPENOFFICE) {
|
||||
$x = (int) $x;
|
||||
} else {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
}
|
||||
$x = (string) $x;
|
||||
if (strlen($x) > preg_match_all('/[-0123456789.]/', $x, $out)) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
$x = (string) floor($x);
|
||||
$r = decoct($x);
|
||||
|
@ -1474,15 +1474,15 @@ class Engineering
|
|||
*/
|
||||
public static function HEXTOBIN($x, $places = null)
|
||||
{
|
||||
$x = PHPExcel_Calculation_Functions::flattenSingleValue($x);
|
||||
$places = PHPExcel_Calculation_Functions::flattenSingleValue($places);
|
||||
$x = Functions::flattenSingleValue($x);
|
||||
$places = Functions::flattenSingleValue($places);
|
||||
|
||||
if (is_bool($x)) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
$x = (string) $x;
|
||||
if (strlen($x) > preg_match_all('/[0123456789ABCDEF]/', strtoupper($x), $out)) {
|
||||
return PHPExcel_Calculation_Functions::NaN();
|
||||
return Functions::NaN();
|
||||
}
|
||||
$binVal = decbin(hexdec($x));
|
||||
|
||||
|
@ -1511,14 +1511,14 @@ class Engineering
|
|||
*/
|
||||
public static function HEXTODEC($x)
|
||||
{
|
||||
$x = PHPExcel_Calculation_Functions::flattenSingleValue($x);
|
||||
$x = Functions::flattenSingleValue($x);
|
||||
|
||||
if (is_bool($x)) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
$x = (string) $x;
|
||||
if (strlen($x) > preg_match_all('/[0123456789ABCDEF]/', strtoupper($x), $out)) {
|
||||
return PHPExcel_Calculation_Functions::NaN();
|
||||
return Functions::NaN();
|
||||
}
|
||||
return hexdec($x);
|
||||
}
|
||||
|
@ -1558,15 +1558,15 @@ class Engineering
|
|||
*/
|
||||
public static function HEXTOOCT($x, $places = null)
|
||||
{
|
||||
$x = PHPExcel_Calculation_Functions::flattenSingleValue($x);
|
||||
$places = PHPExcel_Calculation_Functions::flattenSingleValue($places);
|
||||
$x = Functions::flattenSingleValue($x);
|
||||
$places = Functions::flattenSingleValue($places);
|
||||
|
||||
if (is_bool($x)) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
$x = (string) $x;
|
||||
if (strlen($x) > preg_match_all('/[0123456789ABCDEF]/', strtoupper($x), $out)) {
|
||||
return PHPExcel_Calculation_Functions::NaN();
|
||||
return Functions::NaN();
|
||||
}
|
||||
$octVal = decoct(hexdec($x));
|
||||
|
||||
|
@ -1610,15 +1610,15 @@ class Engineering
|
|||
*/
|
||||
public static function OCTTOBIN($x, $places = null)
|
||||
{
|
||||
$x = PHPExcel_Calculation_Functions::flattenSingleValue($x);
|
||||
$places = PHPExcel_Calculation_Functions::flattenSingleValue($places);
|
||||
$x = Functions::flattenSingleValue($x);
|
||||
$places = Functions::flattenSingleValue($places);
|
||||
|
||||
if (is_bool($x)) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
$x = (string) $x;
|
||||
if (preg_match_all('/[01234567]/', $x, $out) != strlen($x)) {
|
||||
return PHPExcel_Calculation_Functions::NaN();
|
||||
return Functions::NaN();
|
||||
}
|
||||
$r = decbin(octdec($x));
|
||||
|
||||
|
@ -1647,14 +1647,14 @@ class Engineering
|
|||
*/
|
||||
public static function OCTTODEC($x)
|
||||
{
|
||||
$x = PHPExcel_Calculation_Functions::flattenSingleValue($x);
|
||||
$x = Functions::flattenSingleValue($x);
|
||||
|
||||
if (is_bool($x)) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
$x = (string) $x;
|
||||
if (preg_match_all('/[01234567]/', $x, $out) != strlen($x)) {
|
||||
return PHPExcel_Calculation_Functions::NaN();
|
||||
return Functions::NaN();
|
||||
}
|
||||
return octdec($x);
|
||||
}
|
||||
|
@ -1691,15 +1691,15 @@ class Engineering
|
|||
*/
|
||||
public static function OCTTOHEX($x, $places = null)
|
||||
{
|
||||
$x = PHPExcel_Calculation_Functions::flattenSingleValue($x);
|
||||
$places = PHPExcel_Calculation_Functions::flattenSingleValue($places);
|
||||
$x = Functions::flattenSingleValue($x);
|
||||
$places = Functions::flattenSingleValue($places);
|
||||
|
||||
if (is_bool($x)) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
$x = (string) $x;
|
||||
if (preg_match_all('/[01234567]/', $x, $out) != strlen($x)) {
|
||||
return PHPExcel_Calculation_Functions::NaN();
|
||||
return Functions::NaN();
|
||||
}
|
||||
$hexVal = strtoupper(dechex(octdec($x)));
|
||||
|
||||
|
@ -1725,9 +1725,9 @@ class Engineering
|
|||
*/
|
||||
public static function COMPLEX($realNumber = 0.0, $imaginary = 0.0, $suffix = 'i')
|
||||
{
|
||||
$realNumber = (is_null($realNumber)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($realNumber);
|
||||
$imaginary = (is_null($imaginary)) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($imaginary);
|
||||
$suffix = (is_null($suffix)) ? 'i' : PHPExcel_Calculation_Functions::flattenSingleValue($suffix);
|
||||
$realNumber = (is_null($realNumber)) ? 0.0 : Functions::flattenSingleValue($realNumber);
|
||||
$imaginary = (is_null($imaginary)) ? 0.0 : Functions::flattenSingleValue($imaginary);
|
||||
$suffix = (is_null($suffix)) ? 'i' : Functions::flattenSingleValue($suffix);
|
||||
|
||||
if (((is_numeric($realNumber)) && (is_numeric($imaginary))) &&
|
||||
(($suffix == 'i') || ($suffix == 'j') || ($suffix == ''))) {
|
||||
|
@ -1759,7 +1759,7 @@ class Engineering
|
|||
return (string) $realNumber.$imaginary.$suffix;
|
||||
}
|
||||
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
|
||||
|
@ -1779,7 +1779,7 @@ class Engineering
|
|||
*/
|
||||
public static function IMAGINARY($complexNumber)
|
||||
{
|
||||
$complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber);
|
||||
$complexNumber = Functions::flattenSingleValue($complexNumber);
|
||||
|
||||
$parsedComplex = self::parseComplex($complexNumber);
|
||||
return $parsedComplex['imaginary'];
|
||||
|
@ -1801,7 +1801,7 @@ class Engineering
|
|||
*/
|
||||
public static function IMREAL($complexNumber)
|
||||
{
|
||||
$complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber);
|
||||
$complexNumber = Functions::flattenSingleValue($complexNumber);
|
||||
|
||||
$parsedComplex = self::parseComplex($complexNumber);
|
||||
return $parsedComplex['real'];
|
||||
|
@ -1821,7 +1821,7 @@ class Engineering
|
|||
*/
|
||||
public static function IMABS($complexNumber)
|
||||
{
|
||||
$complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber);
|
||||
$complexNumber = Functions::flattenSingleValue($complexNumber);
|
||||
|
||||
$parsedComplex = self::parseComplex($complexNumber);
|
||||
|
||||
|
@ -1846,7 +1846,7 @@ class Engineering
|
|||
*/
|
||||
public static function IMARGUMENT($complexNumber)
|
||||
{
|
||||
$complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber);
|
||||
$complexNumber = Functions::flattenSingleValue($complexNumber);
|
||||
|
||||
$parsedComplex = self::parseComplex($complexNumber);
|
||||
|
||||
|
@ -1881,7 +1881,7 @@ class Engineering
|
|||
*/
|
||||
public static function IMCONJUGATE($complexNumber)
|
||||
{
|
||||
$complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber);
|
||||
$complexNumber = Functions::flattenSingleValue($complexNumber);
|
||||
|
||||
$parsedComplex = self::parseComplex($complexNumber);
|
||||
|
||||
|
@ -1912,7 +1912,7 @@ class Engineering
|
|||
*/
|
||||
public static function IMCOS($complexNumber)
|
||||
{
|
||||
$complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber);
|
||||
$complexNumber = Functions::flattenSingleValue($complexNumber);
|
||||
|
||||
$parsedComplex = self::parseComplex($complexNumber);
|
||||
|
||||
|
@ -1943,7 +1943,7 @@ class Engineering
|
|||
*/
|
||||
public static function IMSIN($complexNumber)
|
||||
{
|
||||
$complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber);
|
||||
$complexNumber = Functions::flattenSingleValue($complexNumber);
|
||||
|
||||
$parsedComplex = self::parseComplex($complexNumber);
|
||||
|
||||
|
@ -1972,7 +1972,7 @@ class Engineering
|
|||
*/
|
||||
public static function IMSQRT($complexNumber)
|
||||
{
|
||||
$complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber);
|
||||
$complexNumber = Functions::flattenSingleValue($complexNumber);
|
||||
|
||||
$parsedComplex = self::parseComplex($complexNumber);
|
||||
|
||||
|
@ -2002,12 +2002,12 @@ class Engineering
|
|||
*/
|
||||
public static function IMLN($complexNumber)
|
||||
{
|
||||
$complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber);
|
||||
$complexNumber = Functions::flattenSingleValue($complexNumber);
|
||||
|
||||
$parsedComplex = self::parseComplex($complexNumber);
|
||||
|
||||
if (($parsedComplex['real'] == 0.0) && ($parsedComplex['imaginary'] == 0.0)) {
|
||||
return PHPExcel_Calculation_Functions::NaN();
|
||||
return Functions::NaN();
|
||||
}
|
||||
|
||||
$logR = log(sqrt(($parsedComplex['real'] * $parsedComplex['real']) + ($parsedComplex['imaginary'] * $parsedComplex['imaginary'])));
|
||||
|
@ -2034,12 +2034,12 @@ class Engineering
|
|||
*/
|
||||
public static function IMLOG10($complexNumber)
|
||||
{
|
||||
$complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber);
|
||||
$complexNumber = Functions::flattenSingleValue($complexNumber);
|
||||
|
||||
$parsedComplex = self::parseComplex($complexNumber);
|
||||
|
||||
if (($parsedComplex['real'] == 0.0) && ($parsedComplex['imaginary'] == 0.0)) {
|
||||
return PHPExcel_Calculation_Functions::NaN();
|
||||
return Functions::NaN();
|
||||
} elseif (($parsedComplex['real'] > 0.0) && ($parsedComplex['imaginary'] == 0.0)) {
|
||||
return log10($parsedComplex['real']);
|
||||
}
|
||||
|
@ -2061,12 +2061,12 @@ class Engineering
|
|||
*/
|
||||
public static function IMLOG2($complexNumber)
|
||||
{
|
||||
$complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber);
|
||||
$complexNumber = Functions::flattenSingleValue($complexNumber);
|
||||
|
||||
$parsedComplex = self::parseComplex($complexNumber);
|
||||
|
||||
if (($parsedComplex['real'] == 0.0) && ($parsedComplex['imaginary'] == 0.0)) {
|
||||
return PHPExcel_Calculation_Functions::NaN();
|
||||
return Functions::NaN();
|
||||
} elseif (($parsedComplex['real'] > 0.0) && ($parsedComplex['imaginary'] == 0.0)) {
|
||||
return log($parsedComplex['real'], 2);
|
||||
}
|
||||
|
@ -2088,7 +2088,7 @@ class Engineering
|
|||
*/
|
||||
public static function IMEXP($complexNumber)
|
||||
{
|
||||
$complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber);
|
||||
$complexNumber = Functions::flattenSingleValue($complexNumber);
|
||||
|
||||
$parsedComplex = self::parseComplex($complexNumber);
|
||||
|
||||
|
@ -2122,11 +2122,11 @@ class Engineering
|
|||
*/
|
||||
public static function IMPOWER($complexNumber, $realNumber)
|
||||
{
|
||||
$complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber);
|
||||
$realNumber = PHPExcel_Calculation_Functions::flattenSingleValue($realNumber);
|
||||
$complexNumber = Functions::flattenSingleValue($complexNumber);
|
||||
$realNumber = Functions::flattenSingleValue($realNumber);
|
||||
|
||||
if (!is_numeric($realNumber)) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
$parsedComplex = self::parseComplex($complexNumber);
|
||||
|
@ -2158,15 +2158,15 @@ class Engineering
|
|||
*/
|
||||
public static function IMDIV($complexDividend, $complexDivisor)
|
||||
{
|
||||
$complexDividend = PHPExcel_Calculation_Functions::flattenSingleValue($complexDividend);
|
||||
$complexDivisor = PHPExcel_Calculation_Functions::flattenSingleValue($complexDivisor);
|
||||
$complexDividend = Functions::flattenSingleValue($complexDividend);
|
||||
$complexDivisor = Functions::flattenSingleValue($complexDivisor);
|
||||
|
||||
$parsedComplexDividend = self::parseComplex($complexDividend);
|
||||
$parsedComplexDivisor = self::parseComplex($complexDivisor);
|
||||
|
||||
if (($parsedComplexDividend['suffix'] != '') && ($parsedComplexDivisor['suffix'] != '') &&
|
||||
($parsedComplexDividend['suffix'] != $parsedComplexDivisor['suffix'])) {
|
||||
return PHPExcel_Calculation_Functions::NaN();
|
||||
return Functions::NaN();
|
||||
}
|
||||
if (($parsedComplexDividend['suffix'] != '') && ($parsedComplexDivisor['suffix'] == '')) {
|
||||
$parsedComplexDivisor['suffix'] = $parsedComplexDividend['suffix'];
|
||||
|
@ -2203,15 +2203,15 @@ class Engineering
|
|||
*/
|
||||
public static function IMSUB($complexNumber1, $complexNumber2)
|
||||
{
|
||||
$complexNumber1 = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber1);
|
||||
$complexNumber2 = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber2);
|
||||
$complexNumber1 = Functions::flattenSingleValue($complexNumber1);
|
||||
$complexNumber2 = Functions::flattenSingleValue($complexNumber2);
|
||||
|
||||
$parsedComplex1 = self::parseComplex($complexNumber1);
|
||||
$parsedComplex2 = self::parseComplex($complexNumber2);
|
||||
|
||||
if ((($parsedComplex1['suffix'] != '') && ($parsedComplex2['suffix'] != '')) &&
|
||||
($parsedComplex1['suffix'] != $parsedComplex2['suffix'])) {
|
||||
return PHPExcel_Calculation_Functions::NaN();
|
||||
return Functions::NaN();
|
||||
} elseif (($parsedComplex1['suffix'] == '') && ($parsedComplex2['suffix'] != '')) {
|
||||
$parsedComplex1['suffix'] = $parsedComplex2['suffix'];
|
||||
}
|
||||
|
@ -2241,14 +2241,14 @@ class Engineering
|
|||
$activeSuffix = '';
|
||||
|
||||
// Loop through the arguments
|
||||
$aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
|
||||
$aArgs = Functions::flattenArray(func_get_args());
|
||||
foreach ($aArgs as $arg) {
|
||||
$parsedComplex = self::parseComplex($arg);
|
||||
|
||||
if ($activeSuffix == '') {
|
||||
$activeSuffix = $parsedComplex['suffix'];
|
||||
} elseif (($parsedComplex['suffix'] != '') && ($activeSuffix != $parsedComplex['suffix'])) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
$returnValue['real'] += $parsedComplex['real'];
|
||||
|
@ -2280,7 +2280,7 @@ class Engineering
|
|||
$activeSuffix = '';
|
||||
|
||||
// Loop through the arguments
|
||||
$aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
|
||||
$aArgs = Functions::flattenArray(func_get_args());
|
||||
foreach ($aArgs as $arg) {
|
||||
$parsedComplex = self::parseComplex($arg);
|
||||
|
||||
|
@ -2288,7 +2288,7 @@ class Engineering
|
|||
if (($parsedComplex['suffix'] != '') && ($activeSuffix == '')) {
|
||||
$activeSuffix = $parsedComplex['suffix'];
|
||||
} elseif (($parsedComplex['suffix'] != '') && ($activeSuffix != $parsedComplex['suffix'])) {
|
||||
return PHPExcel_Calculation_Functions::NaN();
|
||||
return Functions::NaN();
|
||||
}
|
||||
$returnValue['real'] = ($workValue['real'] * $parsedComplex['real']) - ($workValue['imaginary'] * $parsedComplex['imaginary']);
|
||||
$returnValue['imaginary'] = ($workValue['real'] * $parsedComplex['imaginary']) + ($workValue['imaginary'] * $parsedComplex['real']);
|
||||
|
@ -2318,8 +2318,8 @@ class Engineering
|
|||
*/
|
||||
public static function DELTA($a, $b = 0)
|
||||
{
|
||||
$a = PHPExcel_Calculation_Functions::flattenSingleValue($a);
|
||||
$b = PHPExcel_Calculation_Functions::flattenSingleValue($b);
|
||||
$a = Functions::flattenSingleValue($a);
|
||||
$b = Functions::flattenSingleValue($b);
|
||||
|
||||
return (int) ($a == $b);
|
||||
}
|
||||
|
@ -2342,8 +2342,8 @@ class Engineering
|
|||
*/
|
||||
public static function GESTEP($number, $step = 0)
|
||||
{
|
||||
$number = PHPExcel_Calculation_Functions::flattenSingleValue($number);
|
||||
$step = PHPExcel_Calculation_Functions::flattenSingleValue($step);
|
||||
$number = Functions::flattenSingleValue($number);
|
||||
$step = Functions::flattenSingleValue($step);
|
||||
|
||||
return (int) ($number >= $step);
|
||||
}
|
||||
|
@ -2397,8 +2397,8 @@ class Engineering
|
|||
*/
|
||||
public static function ERF($lower, $upper = null)
|
||||
{
|
||||
$lower = PHPExcel_Calculation_Functions::flattenSingleValue($lower);
|
||||
$upper = PHPExcel_Calculation_Functions::flattenSingleValue($upper);
|
||||
$lower = Functions::flattenSingleValue($lower);
|
||||
$upper = Functions::flattenSingleValue($upper);
|
||||
|
||||
if (is_numeric($lower)) {
|
||||
if (is_null($upper)) {
|
||||
|
@ -2408,7 +2408,7 @@ class Engineering
|
|||
return self::erfVal($upper) - self::erfVal($lower);
|
||||
}
|
||||
}
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
|
||||
|
@ -2463,12 +2463,12 @@ class Engineering
|
|||
*/
|
||||
public static function ERFC($x)
|
||||
{
|
||||
$x = PHPExcel_Calculation_Functions::flattenSingleValue($x);
|
||||
$x = Functions::flattenSingleValue($x);
|
||||
|
||||
if (is_numeric($x)) {
|
||||
return self::erfcVal($x);
|
||||
}
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
|
||||
|
@ -2558,12 +2558,12 @@ class Engineering
|
|||
*/
|
||||
public static function CONVERTUOM($value, $fromUOM, $toUOM)
|
||||
{
|
||||
$value = PHPExcel_Calculation_Functions::flattenSingleValue($value);
|
||||
$fromUOM = PHPExcel_Calculation_Functions::flattenSingleValue($fromUOM);
|
||||
$toUOM = PHPExcel_Calculation_Functions::flattenSingleValue($toUOM);
|
||||
$value = Functions::flattenSingleValue($value);
|
||||
$fromUOM = Functions::flattenSingleValue($fromUOM);
|
||||
$toUOM = Functions::flattenSingleValue($toUOM);
|
||||
|
||||
if (!is_numeric($value)) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
$fromMultiplier = 1.0;
|
||||
if (isset(self::$conversionUnits[$fromUOM])) {
|
||||
|
@ -2574,12 +2574,12 @@ class Engineering
|
|||
if (isset(self::$conversionMultipliers[$fromMultiplier])) {
|
||||
$fromMultiplier = self::$conversionMultipliers[$fromMultiplier]['multiplier'];
|
||||
} else {
|
||||
return PHPExcel_Calculation_Functions::NA();
|
||||
return Functions::NA();
|
||||
}
|
||||
if ((isset(self::$conversionUnits[$fromUOM])) && (self::$conversionUnits[$fromUOM]['AllowPrefix'])) {
|
||||
$unitGroup1 = self::$conversionUnits[$fromUOM]['Group'];
|
||||
} else {
|
||||
return PHPExcel_Calculation_Functions::NA();
|
||||
return Functions::NA();
|
||||
}
|
||||
}
|
||||
$value *= $fromMultiplier;
|
||||
|
@ -2593,16 +2593,16 @@ class Engineering
|
|||
if (isset(self::$conversionMultipliers[$toMultiplier])) {
|
||||
$toMultiplier = self::$conversionMultipliers[$toMultiplier]['multiplier'];
|
||||
} else {
|
||||
return PHPExcel_Calculation_Functions::NA();
|
||||
return Functions::NA();
|
||||
}
|
||||
if ((isset(self::$conversionUnits[$toUOM])) && (self::$conversionUnits[$toUOM]['AllowPrefix'])) {
|
||||
$unitGroup2 = self::$conversionUnits[$toUOM]['Group'];
|
||||
} else {
|
||||
return PHPExcel_Calculation_Functions::NA();
|
||||
return Functions::NA();
|
||||
}
|
||||
}
|
||||
if ($unitGroup1 != $unitGroup2) {
|
||||
return PHPExcel_Calculation_Functions::NA();
|
||||
return Functions::NA();
|
||||
}
|
||||
|
||||
if (($fromUOM == $toUOM) && ($fromMultiplier == $toMultiplier)) {
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -42,7 +42,6 @@ define('PRECISION', 8.88E-016);
|
|||
*/
|
||||
class Functions
|
||||
{
|
||||
|
||||
/** constants */
|
||||
const COMPATIBILITY_EXCEL = 'Excel';
|
||||
const COMPATIBILITY_GNUMERIC = 'Gnumeric';
|
||||
|
@ -94,9 +93,9 @@ class Functions
|
|||
* @category Function Configuration
|
||||
* @param string $compatibilityMode Compatibility Mode
|
||||
* Permitted values are:
|
||||
* PHPExcel_Calculation_Functions::COMPATIBILITY_EXCEL 'Excel'
|
||||
* PHPExcel_Calculation_Functions::COMPATIBILITY_GNUMERIC 'Gnumeric'
|
||||
* PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE 'OpenOfficeCalc'
|
||||
* Functions::COMPATIBILITY_EXCEL 'Excel'
|
||||
* Functions::COMPATIBILITY_GNUMERIC 'Gnumeric'
|
||||
* Functions::COMPATIBILITY_OPENOFFICE 'OpenOfficeCalc'
|
||||
* @return boolean (Success or Failure)
|
||||
*/
|
||||
public static function setCompatibilityMode($compatibilityMode)
|
||||
|
@ -118,9 +117,9 @@ class Functions
|
|||
* @category Function Configuration
|
||||
* @return string Compatibility Mode
|
||||
* Possible Return values are:
|
||||
* PHPExcel_Calculation_Functions::COMPATIBILITY_EXCEL 'Excel'
|
||||
* PHPExcel_Calculation_Functions::COMPATIBILITY_GNUMERIC 'Gnumeric'
|
||||
* PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE 'OpenOfficeCalc'
|
||||
* Functions::COMPATIBILITY_EXCEL 'Excel'
|
||||
* Functions::COMPATIBILITY_GNUMERIC 'Gnumeric'
|
||||
* Functions::COMPATIBILITY_OPENOFFICE 'OpenOfficeCalc'
|
||||
*/
|
||||
public static function getCompatibilityMode()
|
||||
{
|
||||
|
@ -135,9 +134,9 @@ class Functions
|
|||
* @category Function Configuration
|
||||
* @param string $returnDateType Return Date Format
|
||||
* Permitted values are:
|
||||
* PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC 'P'
|
||||
* PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT 'O'
|
||||
* PHPExcel_Calculation_Functions::RETURNDATE_EXCEL 'E'
|
||||
* Functions::RETURNDATE_PHP_NUMERIC 'P'
|
||||
* Functions::RETURNDATE_PHP_OBJECT 'O'
|
||||
* Functions::RETURNDATE_EXCEL 'E'
|
||||
* @return boolean Success or failure
|
||||
*/
|
||||
public static function setReturnDateType($returnDateType)
|
||||
|
@ -159,9 +158,9 @@ class Functions
|
|||
* @category Function Configuration
|
||||
* @return string Return Date Format
|
||||
* Possible Return values are:
|
||||
* PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC 'P'
|
||||
* PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT 'O'
|
||||
* PHPExcel_Calculation_Functions::RETURNDATE_EXCEL 'E'
|
||||
* Functions::RETURNDATE_PHP_NUMERIC 'P'
|
||||
* Functions::RETURNDATE_PHP_OBJECT 'O'
|
||||
* Functions::RETURNDATE_EXCEL 'E'
|
||||
*/
|
||||
public static function getReturnDateType()
|
||||
{
|
||||
|
@ -309,7 +308,7 @@ class Functions
|
|||
|
||||
public static function ifCondition($condition)
|
||||
{
|
||||
$condition = PHPExcel_Calculation_Functions::flattenSingleValue($condition);
|
||||
$condition = Functions::flattenSingleValue($condition);
|
||||
if (!isset($condition{0})) {
|
||||
$condition = '=""';
|
||||
}
|
||||
|
|
|
@ -92,7 +92,7 @@ class PHPExcel_Calculation_Logical
|
|||
$returnValue = true;
|
||||
|
||||
// Loop through the arguments
|
||||
$aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
|
||||
$aArgs = Functions::flattenArray(func_get_args());
|
||||
$argCount = -1;
|
||||
foreach ($aArgs as $argCount => $arg) {
|
||||
// Is it a boolean value?
|
||||
|
@ -107,7 +107,7 @@ class PHPExcel_Calculation_Logical
|
|||
} elseif (($arg == 'FALSE') || ($arg == PHPExcel_Calculation::getFALSE())) {
|
||||
$arg = false;
|
||||
} else {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
$returnValue = $returnValue && ($arg != 0);
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ class PHPExcel_Calculation_Logical
|
|||
|
||||
// Return
|
||||
if ($argCount < 0) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
return $returnValue;
|
||||
}
|
||||
|
@ -148,7 +148,7 @@ class PHPExcel_Calculation_Logical
|
|||
$returnValue = false;
|
||||
|
||||
// Loop through the arguments
|
||||
$aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
|
||||
$aArgs = Functions::flattenArray(func_get_args());
|
||||
$argCount = -1;
|
||||
foreach ($aArgs as $argCount => $arg) {
|
||||
// Is it a boolean value?
|
||||
|
@ -163,7 +163,7 @@ class PHPExcel_Calculation_Logical
|
|||
} elseif (($arg == 'FALSE') || ($arg == PHPExcel_Calculation::getFALSE())) {
|
||||
$arg = false;
|
||||
} else {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
$returnValue = $returnValue || ($arg != 0);
|
||||
}
|
||||
|
@ -171,7 +171,7 @@ class PHPExcel_Calculation_Logical
|
|||
|
||||
// Return
|
||||
if ($argCount < 0) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
return $returnValue;
|
||||
}
|
||||
|
@ -199,7 +199,7 @@ class PHPExcel_Calculation_Logical
|
|||
*/
|
||||
public static function NOT($logical = false)
|
||||
{
|
||||
$logical = PHPExcel_Calculation_Functions::flattenSingleValue($logical);
|
||||
$logical = Functions::flattenSingleValue($logical);
|
||||
if (is_string($logical)) {
|
||||
$logical = strtoupper($logical);
|
||||
if (($logical == 'TRUE') || ($logical == PHPExcel_Calculation::getTRUE())) {
|
||||
|
@ -207,7 +207,7 @@ class PHPExcel_Calculation_Logical
|
|||
} elseif (($logical == 'FALSE') || ($logical == PHPExcel_Calculation::getFALSE())) {
|
||||
return true;
|
||||
} else {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -248,9 +248,9 @@ class PHPExcel_Calculation_Logical
|
|||
*/
|
||||
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);
|
||||
$condition = (is_null($condition)) ? true : (boolean) Functions::flattenSingleValue($condition);
|
||||
$returnIfTrue = (is_null($returnIfTrue)) ? 0 : Functions::flattenSingleValue($returnIfTrue);
|
||||
$returnIfFalse = (is_null($returnIfFalse)) ? false : Functions::flattenSingleValue($returnIfFalse);
|
||||
|
||||
return ($condition) ? $returnIfTrue : $returnIfFalse;
|
||||
}
|
||||
|
@ -270,9 +270,9 @@ class PHPExcel_Calculation_Logical
|
|||
*/
|
||||
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)) ? '' : Functions::flattenSingleValue($testValue);
|
||||
$errorpart = (is_null($errorpart)) ? '' : Functions::flattenSingleValue($errorpart);
|
||||
|
||||
return self::STATEMENT_IF(PHPExcel_Calculation_Functions::IS_ERROR($testValue), $errorpart, $testValue);
|
||||
return self::STATEMENT_IF(Functions::IS_ERROR($testValue), $errorpart, $testValue);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,13 +52,13 @@ class LookupRef
|
|||
*/
|
||||
public static function CELL_ADDRESS($row, $column, $relativity = 1, $referenceStyle = true, $sheetText = '')
|
||||
{
|
||||
$row = PHPExcel_Calculation_Functions::flattenSingleValue($row);
|
||||
$column = PHPExcel_Calculation_Functions::flattenSingleValue($column);
|
||||
$relativity = PHPExcel_Calculation_Functions::flattenSingleValue($relativity);
|
||||
$sheetText = PHPExcel_Calculation_Functions::flattenSingleValue($sheetText);
|
||||
$row = Functions::flattenSingleValue($row);
|
||||
$column = Functions::flattenSingleValue($column);
|
||||
$relativity = Functions::flattenSingleValue($relativity);
|
||||
$sheetText = Functions::flattenSingleValue($sheetText);
|
||||
|
||||
if (($row < 1) || ($column < 1)) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
if ($sheetText > '') {
|
||||
|
@ -151,7 +151,7 @@ class LookupRef
|
|||
if (is_null($cellAddress) || $cellAddress === '') {
|
||||
return 1;
|
||||
} elseif (!is_array($cellAddress)) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
reset($cellAddress);
|
||||
|
@ -229,7 +229,7 @@ class LookupRef
|
|||
if (is_null($cellAddress) || $cellAddress === '') {
|
||||
return 1;
|
||||
} elseif (!is_array($cellAddress)) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
reset($cellAddress);
|
||||
|
@ -262,11 +262,11 @@ class LookupRef
|
|||
$args = func_get_args();
|
||||
$pCell = array_pop($args);
|
||||
|
||||
$linkURL = (is_null($linkURL)) ? '' : PHPExcel_Calculation_Functions::flattenSingleValue($linkURL);
|
||||
$displayName = (is_null($displayName)) ? '' : PHPExcel_Calculation_Functions::flattenSingleValue($displayName);
|
||||
$linkURL = (is_null($linkURL)) ? '' : Functions::flattenSingleValue($linkURL);
|
||||
$displayName = (is_null($displayName)) ? '' : Functions::flattenSingleValue($displayName);
|
||||
|
||||
if ((!is_object($pCell)) || (trim($linkURL) == '')) {
|
||||
return PHPExcel_Calculation_Functions::REF();
|
||||
return Functions::REF();
|
||||
}
|
||||
|
||||
if ((is_object($displayName)) || trim($displayName) == '') {
|
||||
|
@ -299,9 +299,9 @@ class LookupRef
|
|||
*/
|
||||
public static function INDIRECT($cellAddress = null, PHPExcel_Cell $pCell = null)
|
||||
{
|
||||
$cellAddress = PHPExcel_Calculation_Functions::flattenSingleValue($cellAddress);
|
||||
$cellAddress = Functions::flattenSingleValue($cellAddress);
|
||||
if (is_null($cellAddress) || $cellAddress === '') {
|
||||
return PHPExcel_Calculation_Functions::REF();
|
||||
return Functions::REF();
|
||||
}
|
||||
|
||||
$cellAddress1 = $cellAddress;
|
||||
|
@ -313,7 +313,7 @@ class LookupRef
|
|||
if ((!preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_CELLREF.'$/i', $cellAddress1, $matches)) ||
|
||||
((!is_null($cellAddress2)) && (!preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_CELLREF.'$/i', $cellAddress2, $matches)))) {
|
||||
if (!preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_NAMEDRANGE.'$/i', $cellAddress1, $matches)) {
|
||||
return PHPExcel_Calculation_Functions::REF();
|
||||
return Functions::REF();
|
||||
}
|
||||
|
||||
if (strpos($cellAddress, '!') !== false) {
|
||||
|
@ -366,10 +366,10 @@ class LookupRef
|
|||
*/
|
||||
public static function OFFSET($cellAddress = null, $rows = 0, $columns = 0, $height = null, $width = null)
|
||||
{
|
||||
$rows = PHPExcel_Calculation_Functions::flattenSingleValue($rows);
|
||||
$columns = PHPExcel_Calculation_Functions::flattenSingleValue($columns);
|
||||
$height = PHPExcel_Calculation_Functions::flattenSingleValue($height);
|
||||
$width = PHPExcel_Calculation_Functions::flattenSingleValue($width);
|
||||
$rows = Functions::flattenSingleValue($rows);
|
||||
$columns = Functions::flattenSingleValue($columns);
|
||||
$height = Functions::flattenSingleValue($height);
|
||||
$width = Functions::flattenSingleValue($width);
|
||||
if ($cellAddress == null) {
|
||||
return 0;
|
||||
}
|
||||
|
@ -377,7 +377,7 @@ class LookupRef
|
|||
$args = func_get_args();
|
||||
$pCell = array_pop($args);
|
||||
if (!is_object($pCell)) {
|
||||
return PHPExcel_Calculation_Functions::REF();
|
||||
return Functions::REF();
|
||||
}
|
||||
|
||||
$sheetName = null;
|
||||
|
@ -398,7 +398,7 @@ class LookupRef
|
|||
$startCellColumn += $columns;
|
||||
|
||||
if (($startCellRow <= 0) || ($startCellColumn < 0)) {
|
||||
return PHPExcel_Calculation_Functions::REF();
|
||||
return Functions::REF();
|
||||
}
|
||||
$endCellColumn = PHPExcel_Cell::columnIndexFromString($endCellColumn) - 1;
|
||||
if (($width != null) && (!is_object($width))) {
|
||||
|
@ -415,7 +415,7 @@ class LookupRef
|
|||
}
|
||||
|
||||
if (($endCellRow <= 0) || ($endCellColumn < 0)) {
|
||||
return PHPExcel_Calculation_Functions::REF();
|
||||
return Functions::REF();
|
||||
}
|
||||
$endCellColumn = PHPExcel_Cell::stringFromColumnIndex($endCellColumn);
|
||||
|
||||
|
@ -455,7 +455,7 @@ class LookupRef
|
|||
public static function CHOOSE()
|
||||
{
|
||||
$chooseArgs = func_get_args();
|
||||
$chosenEntry = PHPExcel_Calculation_Functions::flattenArray(array_shift($chooseArgs));
|
||||
$chosenEntry = Functions::flattenArray(array_shift($chooseArgs));
|
||||
$entryCount = count($chooseArgs) - 1;
|
||||
|
||||
if (is_array($chosenEntry)) {
|
||||
|
@ -464,15 +464,15 @@ class LookupRef
|
|||
if ((is_numeric($chosenEntry)) && (!is_bool($chosenEntry))) {
|
||||
--$chosenEntry;
|
||||
} else {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
$chosenEntry = floor($chosenEntry);
|
||||
if (($chosenEntry < 0) || ($chosenEntry > $entryCount)) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
if (is_array($chooseArgs[$chosenEntry])) {
|
||||
return PHPExcel_Calculation_Functions::flattenArray($chooseArgs[$chosenEntry]);
|
||||
return Functions::flattenArray($chooseArgs[$chosenEntry]);
|
||||
} else {
|
||||
return $chooseArgs[$chosenEntry];
|
||||
}
|
||||
|
@ -494,26 +494,26 @@ class LookupRef
|
|||
*/
|
||||
public static function MATCH($lookup_value, $lookup_array, $match_type = 1)
|
||||
{
|
||||
$lookup_array = PHPExcel_Calculation_Functions::flattenArray($lookup_array);
|
||||
$lookup_value = PHPExcel_Calculation_Functions::flattenSingleValue($lookup_value);
|
||||
$match_type = (is_null($match_type)) ? 1 : (int) PHPExcel_Calculation_Functions::flattenSingleValue($match_type);
|
||||
$lookup_array = Functions::flattenArray($lookup_array);
|
||||
$lookup_value = Functions::flattenSingleValue($lookup_value);
|
||||
$match_type = (is_null($match_type)) ? 1 : (int) Functions::flattenSingleValue($match_type);
|
||||
// MATCH is not case sensitive
|
||||
$lookup_value = strtolower($lookup_value);
|
||||
|
||||
// lookup_value type has to be number, text, or logical values
|
||||
if ((!is_numeric($lookup_value)) && (!is_string($lookup_value)) && (!is_bool($lookup_value))) {
|
||||
return PHPExcel_Calculation_Functions::NA();
|
||||
return Functions::NA();
|
||||
}
|
||||
|
||||
// match_type is 0, 1 or -1
|
||||
if (($match_type !== 0) && ($match_type !== -1) && ($match_type !== 1)) {
|
||||
return PHPExcel_Calculation_Functions::NA();
|
||||
return Functions::NA();
|
||||
}
|
||||
|
||||
// lookup_array should not be empty
|
||||
$lookupArraySize = count($lookup_array);
|
||||
if ($lookupArraySize <= 0) {
|
||||
return PHPExcel_Calculation_Functions::NA();
|
||||
return Functions::NA();
|
||||
}
|
||||
|
||||
// lookup_array should contain only number, text, or logical values, or empty (null) cells
|
||||
|
@ -521,7 +521,7 @@ class LookupRef
|
|||
// check the type of the value
|
||||
if ((!is_numeric($lookupArrayValue)) && (!is_string($lookupArrayValue)) &&
|
||||
(!is_bool($lookupArrayValue)) && (!is_null($lookupArrayValue))) {
|
||||
return PHPExcel_Calculation_Functions::NA();
|
||||
return Functions::NA();
|
||||
}
|
||||
// convert strings to lowercase for case-insensitive testing
|
||||
if (is_string($lookupArrayValue)) {
|
||||
|
@ -572,7 +572,7 @@ class LookupRef
|
|||
}
|
||||
|
||||
// unsuccessful in finding a match, return #N/A error value
|
||||
return PHPExcel_Calculation_Functions::NA();
|
||||
return Functions::NA();
|
||||
}
|
||||
|
||||
|
||||
|
@ -592,18 +592,18 @@ class LookupRef
|
|||
public static function INDEX($arrayValues, $rowNum = 0, $columnNum = 0)
|
||||
{
|
||||
if (($rowNum < 0) || ($columnNum < 0)) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
if (!is_array($arrayValues)) {
|
||||
return PHPExcel_Calculation_Functions::REF();
|
||||
return Functions::REF();
|
||||
}
|
||||
|
||||
$rowKeys = array_keys($arrayValues);
|
||||
$columnKeys = @array_keys($arrayValues[$rowKeys[0]]);
|
||||
|
||||
if ($columnNum > count($columnKeys)) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
} elseif ($columnNum == 0) {
|
||||
if ($rowNum == 0) {
|
||||
return $arrayValues;
|
||||
|
@ -625,7 +625,7 @@ class LookupRef
|
|||
}
|
||||
$columnNum = $columnKeys[--$columnNum];
|
||||
if ($rowNum > count($rowKeys)) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
} elseif ($rowNum == 0) {
|
||||
return $arrayValues[$columnNum];
|
||||
}
|
||||
|
@ -685,23 +685,23 @@ class LookupRef
|
|||
*/
|
||||
public static function VLOOKUP($lookup_value, $lookup_array, $index_number, $not_exact_match = true)
|
||||
{
|
||||
$lookup_value = PHPExcel_Calculation_Functions::flattenSingleValue($lookup_value);
|
||||
$index_number = PHPExcel_Calculation_Functions::flattenSingleValue($index_number);
|
||||
$not_exact_match = PHPExcel_Calculation_Functions::flattenSingleValue($not_exact_match);
|
||||
$lookup_value = Functions::flattenSingleValue($lookup_value);
|
||||
$index_number = Functions::flattenSingleValue($index_number);
|
||||
$not_exact_match = Functions::flattenSingleValue($not_exact_match);
|
||||
|
||||
// index_number must be greater than or equal to 1
|
||||
if ($index_number < 1) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
// index_number must be less than or equal to the number of columns in lookup_array
|
||||
if ((!is_array($lookup_array)) || (empty($lookup_array))) {
|
||||
return PHPExcel_Calculation_Functions::REF();
|
||||
return Functions::REF();
|
||||
} else {
|
||||
$f = array_keys($lookup_array);
|
||||
$firstRow = array_pop($f);
|
||||
if ((!is_array($lookup_array[$firstRow])) || ($index_number > count($lookup_array[$firstRow]))) {
|
||||
return PHPExcel_Calculation_Functions::REF();
|
||||
return Functions::REF();
|
||||
} else {
|
||||
$columnKeys = array_keys($lookup_array[$firstRow]);
|
||||
$returnColumn = $columnKeys[--$index_number];
|
||||
|
@ -726,14 +726,14 @@ class LookupRef
|
|||
if ($rowNumber !== false) {
|
||||
if ((!$not_exact_match) && ($rowValue != $lookup_value)) {
|
||||
// if an exact match is required, we have what we need to return an appropriate response
|
||||
return PHPExcel_Calculation_Functions::NA();
|
||||
return Functions::NA();
|
||||
} else {
|
||||
// otherwise return the appropriate value
|
||||
return $lookup_array[$rowNumber][$returnColumn];
|
||||
}
|
||||
}
|
||||
|
||||
return PHPExcel_Calculation_Functions::NA();
|
||||
return Functions::NA();
|
||||
}
|
||||
|
||||
|
||||
|
@ -748,23 +748,23 @@ class LookupRef
|
|||
*/
|
||||
public static function HLOOKUP($lookup_value, $lookup_array, $index_number, $not_exact_match = true)
|
||||
{
|
||||
$lookup_value = PHPExcel_Calculation_Functions::flattenSingleValue($lookup_value);
|
||||
$index_number = PHPExcel_Calculation_Functions::flattenSingleValue($index_number);
|
||||
$not_exact_match = PHPExcel_Calculation_Functions::flattenSingleValue($not_exact_match);
|
||||
$lookup_value = Functions::flattenSingleValue($lookup_value);
|
||||
$index_number = Functions::flattenSingleValue($index_number);
|
||||
$not_exact_match = Functions::flattenSingleValue($not_exact_match);
|
||||
|
||||
// index_number must be greater than or equal to 1
|
||||
if ($index_number < 1) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
// index_number must be less than or equal to the number of columns in lookup_array
|
||||
if ((!is_array($lookup_array)) || (empty($lookup_array))) {
|
||||
return PHPExcel_Calculation_Functions::REF();
|
||||
return Functions::REF();
|
||||
} else {
|
||||
$f = array_keys($lookup_array);
|
||||
$firstRow = array_pop($f);
|
||||
if ((!is_array($lookup_array[$firstRow])) || ($index_number > count($lookup_array[$firstRow]))) {
|
||||
return PHPExcel_Calculation_Functions::REF();
|
||||
return Functions::REF();
|
||||
} else {
|
||||
$columnKeys = array_keys($lookup_array[$firstRow]);
|
||||
$firstkey = $f[0] - 1;
|
||||
|
@ -790,14 +790,14 @@ class LookupRef
|
|||
if ($rowNumber !== false) {
|
||||
if ((!$not_exact_match) && ($rowValue != $lookup_value)) {
|
||||
// if an exact match is required, we have what we need to return an appropriate response
|
||||
return PHPExcel_Calculation_Functions::NA();
|
||||
return Functions::NA();
|
||||
} else {
|
||||
// otherwise return the appropriate value
|
||||
return $lookup_array[$returnColumn][$rowNumber];
|
||||
}
|
||||
}
|
||||
|
||||
return PHPExcel_Calculation_Functions::NA();
|
||||
return Functions::NA();
|
||||
}
|
||||
|
||||
|
||||
|
@ -811,10 +811,10 @@ class LookupRef
|
|||
*/
|
||||
public static function LOOKUP($lookup_value, $lookup_vector, $result_vector = null)
|
||||
{
|
||||
$lookup_value = PHPExcel_Calculation_Functions::flattenSingleValue($lookup_value);
|
||||
$lookup_value = Functions::flattenSingleValue($lookup_value);
|
||||
|
||||
if (!is_array($lookup_vector)) {
|
||||
return PHPExcel_Calculation_Functions::NA();
|
||||
return Functions::NA();
|
||||
}
|
||||
$lookupRows = count($lookup_vector);
|
||||
$l = array_keys($lookup_vector);
|
||||
|
|
|
@ -85,8 +85,8 @@ class MathTrig
|
|||
*/
|
||||
public static function ATAN2($xCoordinate = null, $yCoordinate = null)
|
||||
{
|
||||
$xCoordinate = PHPExcel_Calculation_Functions::flattenSingleValue($xCoordinate);
|
||||
$yCoordinate = PHPExcel_Calculation_Functions::flattenSingleValue($yCoordinate);
|
||||
$xCoordinate = Functions::flattenSingleValue($xCoordinate);
|
||||
$yCoordinate = Functions::flattenSingleValue($yCoordinate);
|
||||
|
||||
$xCoordinate = ($xCoordinate !== null) ? $xCoordinate : 0.0;
|
||||
$yCoordinate = ($yCoordinate !== null) ? $yCoordinate : 0.0;
|
||||
|
@ -97,12 +97,12 @@ class MathTrig
|
|||
$yCoordinate = (float) $yCoordinate;
|
||||
|
||||
if (($xCoordinate == 0) && ($yCoordinate == 0)) {
|
||||
return PHPExcel_Calculation_Functions::DIV0();
|
||||
return Functions::DIV0();
|
||||
}
|
||||
|
||||
return atan2($yCoordinate, $xCoordinate);
|
||||
}
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
|
||||
|
@ -125,11 +125,11 @@ class MathTrig
|
|||
*/
|
||||
public static function CEILING($number, $significance = null)
|
||||
{
|
||||
$number = PHPExcel_Calculation_Functions::flattenSingleValue($number);
|
||||
$significance = PHPExcel_Calculation_Functions::flattenSingleValue($significance);
|
||||
$number = Functions::flattenSingleValue($number);
|
||||
$significance = Functions::flattenSingleValue($significance);
|
||||
|
||||
if ((is_null($significance)) &&
|
||||
(PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_GNUMERIC)) {
|
||||
(Functions::getCompatibilityMode() == Functions::COMPATIBILITY_GNUMERIC)) {
|
||||
$significance = $number / abs($number);
|
||||
}
|
||||
|
||||
|
@ -139,10 +139,10 @@ class MathTrig
|
|||
} elseif (self::SIGN($number) == self::SIGN($significance)) {
|
||||
return ceil($number / $significance) * $significance;
|
||||
} else {
|
||||
return PHPExcel_Calculation_Functions::NaN();
|
||||
return Functions::NaN();
|
||||
}
|
||||
}
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
|
||||
|
@ -163,18 +163,18 @@ class MathTrig
|
|||
*/
|
||||
public static function COMBIN($numObjs, $numInSet)
|
||||
{
|
||||
$numObjs = PHPExcel_Calculation_Functions::flattenSingleValue($numObjs);
|
||||
$numInSet = PHPExcel_Calculation_Functions::flattenSingleValue($numInSet);
|
||||
$numObjs = Functions::flattenSingleValue($numObjs);
|
||||
$numInSet = Functions::flattenSingleValue($numInSet);
|
||||
|
||||
if ((is_numeric($numObjs)) && (is_numeric($numInSet))) {
|
||||
if ($numObjs < $numInSet) {
|
||||
return PHPExcel_Calculation_Functions::NaN();
|
||||
return Functions::NaN();
|
||||
} elseif ($numInSet < 0) {
|
||||
return PHPExcel_Calculation_Functions::NaN();
|
||||
return Functions::NaN();
|
||||
}
|
||||
return round(self::FACT($numObjs) / self::FACT($numObjs - $numInSet)) / self::FACT($numInSet);
|
||||
}
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
|
||||
|
@ -197,7 +197,7 @@ class MathTrig
|
|||
*/
|
||||
public static function EVEN($number)
|
||||
{
|
||||
$number = PHPExcel_Calculation_Functions::flattenSingleValue($number);
|
||||
$number = Functions::flattenSingleValue($number);
|
||||
|
||||
if (is_null($number)) {
|
||||
return 0;
|
||||
|
@ -209,7 +209,7 @@ class MathTrig
|
|||
$significance = 2 * self::SIGN($number);
|
||||
return (int) self::CEILING($number, $significance);
|
||||
}
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
|
||||
|
@ -229,16 +229,16 @@ class MathTrig
|
|||
*/
|
||||
public static function FACT($factVal)
|
||||
{
|
||||
$factVal = PHPExcel_Calculation_Functions::flattenSingleValue($factVal);
|
||||
$factVal = Functions::flattenSingleValue($factVal);
|
||||
|
||||
if (is_numeric($factVal)) {
|
||||
if ($factVal < 0) {
|
||||
return PHPExcel_Calculation_Functions::NaN();
|
||||
return Functions::NaN();
|
||||
}
|
||||
$factLoop = floor($factVal);
|
||||
if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_GNUMERIC) {
|
||||
if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_GNUMERIC) {
|
||||
if ($factVal > $factLoop) {
|
||||
return PHPExcel_Calculation_Functions::NaN();
|
||||
return Functions::NaN();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -248,7 +248,7 @@ class MathTrig
|
|||
}
|
||||
return $factorial ;
|
||||
}
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
|
||||
|
@ -267,12 +267,12 @@ class MathTrig
|
|||
*/
|
||||
public static function FACTDOUBLE($factVal)
|
||||
{
|
||||
$factLoop = PHPExcel_Calculation_Functions::flattenSingleValue($factVal);
|
||||
$factLoop = Functions::flattenSingleValue($factVal);
|
||||
|
||||
if (is_numeric($factLoop)) {
|
||||
$factLoop = floor($factLoop);
|
||||
if ($factVal < 0) {
|
||||
return PHPExcel_Calculation_Functions::NaN();
|
||||
return Functions::NaN();
|
||||
}
|
||||
$factorial = 1;
|
||||
while ($factLoop > 1) {
|
||||
|
@ -281,7 +281,7 @@ class MathTrig
|
|||
}
|
||||
return $factorial ;
|
||||
}
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
|
||||
|
@ -301,27 +301,27 @@ class MathTrig
|
|||
*/
|
||||
public static function FLOOR($number, $significance = null)
|
||||
{
|
||||
$number = PHPExcel_Calculation_Functions::flattenSingleValue($number);
|
||||
$significance = PHPExcel_Calculation_Functions::flattenSingleValue($significance);
|
||||
$number = Functions::flattenSingleValue($number);
|
||||
$significance = Functions::flattenSingleValue($significance);
|
||||
|
||||
if ((is_null($significance)) &&
|
||||
(PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_GNUMERIC)) {
|
||||
(Functions::getCompatibilityMode() == Functions::COMPATIBILITY_GNUMERIC)) {
|
||||
$significance = $number/abs($number);
|
||||
}
|
||||
|
||||
if ((is_numeric($number)) && (is_numeric($significance))) {
|
||||
if ($significance == 0.0) {
|
||||
return PHPExcel_Calculation_Functions::DIV0();
|
||||
return Functions::DIV0();
|
||||
} elseif ($number == 0.0) {
|
||||
return 0.0;
|
||||
} elseif (self::SIGN($number) == self::SIGN($significance)) {
|
||||
return floor($number / $significance) * $significance;
|
||||
} else {
|
||||
return PHPExcel_Calculation_Functions::NaN();
|
||||
return Functions::NaN();
|
||||
}
|
||||
}
|
||||
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
|
||||
|
@ -345,13 +345,13 @@ class MathTrig
|
|||
$returnValue = 1;
|
||||
$allValuesFactors = array();
|
||||
// Loop through arguments
|
||||
foreach (PHPExcel_Calculation_Functions::flattenArray(func_get_args()) as $value) {
|
||||
foreach (Functions::flattenArray(func_get_args()) as $value) {
|
||||
if (!is_numeric($value)) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
} elseif ($value == 0) {
|
||||
continue;
|
||||
} elseif ($value < 0) {
|
||||
return PHPExcel_Calculation_Functions::NaN();
|
||||
return Functions::NaN();
|
||||
}
|
||||
$myFactors = self::factors($value);
|
||||
$myCountedFactors = array_count_values($myFactors);
|
||||
|
@ -417,7 +417,7 @@ class MathTrig
|
|||
*/
|
||||
public static function INT($number)
|
||||
{
|
||||
$number = PHPExcel_Calculation_Functions::flattenSingleValue($number);
|
||||
$number = Functions::flattenSingleValue($number);
|
||||
|
||||
if (is_null($number)) {
|
||||
return 0;
|
||||
|
@ -427,7 +427,7 @@ class MathTrig
|
|||
if (is_numeric($number)) {
|
||||
return (int) floor($number);
|
||||
}
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
|
||||
|
@ -452,14 +452,14 @@ class MathTrig
|
|||
$returnValue = 1;
|
||||
$allPoweredFactors = array();
|
||||
// Loop through arguments
|
||||
foreach (PHPExcel_Calculation_Functions::flattenArray(func_get_args()) as $value) {
|
||||
foreach (Functions::flattenArray(func_get_args()) as $value) {
|
||||
if (!is_numeric($value)) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
if ($value == 0) {
|
||||
return 0;
|
||||
} elseif ($value < 0) {
|
||||
return PHPExcel_Calculation_Functions::NaN();
|
||||
return Functions::NaN();
|
||||
}
|
||||
$myFactors = self::factors(floor($value));
|
||||
$myCountedFactors = array_count_values($myFactors);
|
||||
|
@ -500,14 +500,14 @@ class MathTrig
|
|||
*/
|
||||
public static function LOG_BASE($number = null, $base = 10)
|
||||
{
|
||||
$number = PHPExcel_Calculation_Functions::flattenSingleValue($number);
|
||||
$base = (is_null($base)) ? 10 : (float) PHPExcel_Calculation_Functions::flattenSingleValue($base);
|
||||
$number = Functions::flattenSingleValue($number);
|
||||
$base = (is_null($base)) ? 10 : (float) Functions::flattenSingleValue($base);
|
||||
|
||||
if ((!is_numeric($base)) || (!is_numeric($number))) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
if (($base <= 0) || ($number <= 0)) {
|
||||
return PHPExcel_Calculation_Functions::NaN();
|
||||
return Functions::NaN();
|
||||
}
|
||||
return log($number, $base);
|
||||
}
|
||||
|
@ -541,7 +541,7 @@ class MathTrig
|
|||
$column = 0;
|
||||
foreach ($matrixRow as $matrixCell) {
|
||||
if ((is_string($matrixCell)) || ($matrixCell === null)) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
$matrixData[$column][$row] = $matrixCell;
|
||||
++$column;
|
||||
|
@ -552,14 +552,14 @@ class MathTrig
|
|||
++$row;
|
||||
}
|
||||
if ($row != $maxColumn) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
try {
|
||||
$matrix = new PHPExcel_Shared_JAMA_Matrix($matrixData);
|
||||
return $matrix->det();
|
||||
} catch (PHPExcel_Exception $ex) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -592,7 +592,7 @@ class MathTrig
|
|||
$column = 0;
|
||||
foreach ($matrixRow as $matrixCell) {
|
||||
if ((is_string($matrixCell)) || ($matrixCell === null)) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
$matrixData[$column][$row] = $matrixCell;
|
||||
++$column;
|
||||
|
@ -603,14 +603,14 @@ class MathTrig
|
|||
++$row;
|
||||
}
|
||||
if ($row != $maxColumn) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
try {
|
||||
$matrix = new PHPExcel_Shared_JAMA_Matrix($matrixData);
|
||||
return $matrix->inverse()->getArray();
|
||||
} catch (PHPExcel_Exception $ex) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -641,7 +641,7 @@ class MathTrig
|
|||
$columnA = 0;
|
||||
foreach ($matrixRow as $matrixCell) {
|
||||
if ((!is_numeric($matrixCell)) || ($matrixCell === null)) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
$matrixAData[$rowA][$columnA] = $matrixCell;
|
||||
++$columnA;
|
||||
|
@ -657,7 +657,7 @@ class MathTrig
|
|||
$columnB = 0;
|
||||
foreach ($matrixRow as $matrixCell) {
|
||||
if ((!is_numeric($matrixCell)) || ($matrixCell === null)) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
$matrixBData[$rowB][$columnB] = $matrixCell;
|
||||
++$columnB;
|
||||
|
@ -667,13 +667,13 @@ class MathTrig
|
|||
$matrixB = new PHPExcel_Shared_JAMA_Matrix($matrixBData);
|
||||
|
||||
if ($columnA != $rowB) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
return $matrixA->times($matrixB)->getArray();
|
||||
} catch (PHPExcel_Exception $ex) {
|
||||
var_dump($ex->getMessage());
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -687,11 +687,11 @@ class MathTrig
|
|||
*/
|
||||
public static function MOD($a = 1, $b = 1)
|
||||
{
|
||||
$a = PHPExcel_Calculation_Functions::flattenSingleValue($a);
|
||||
$b = PHPExcel_Calculation_Functions::flattenSingleValue($b);
|
||||
$a = Functions::flattenSingleValue($a);
|
||||
$b = Functions::flattenSingleValue($b);
|
||||
|
||||
if ($b == 0.0) {
|
||||
return PHPExcel_Calculation_Functions::DIV0();
|
||||
return Functions::DIV0();
|
||||
} elseif (($a < 0.0) && ($b > 0.0)) {
|
||||
return $b - fmod(abs($a), $b);
|
||||
} elseif (($a > 0.0) && ($b < 0.0)) {
|
||||
|
@ -713,8 +713,8 @@ class MathTrig
|
|||
*/
|
||||
public static function MROUND($number, $multiple)
|
||||
{
|
||||
$number = PHPExcel_Calculation_Functions::flattenSingleValue($number);
|
||||
$multiple = PHPExcel_Calculation_Functions::flattenSingleValue($multiple);
|
||||
$number = Functions::flattenSingleValue($number);
|
||||
$multiple = Functions::flattenSingleValue($multiple);
|
||||
|
||||
if ((is_numeric($number)) && (is_numeric($multiple))) {
|
||||
if ($multiple == 0) {
|
||||
|
@ -724,9 +724,9 @@ class MathTrig
|
|||
$multiplier = 1 / $multiple;
|
||||
return round($number * $multiplier) / $multiplier;
|
||||
}
|
||||
return PHPExcel_Calculation_Functions::NaN();
|
||||
return Functions::NaN();
|
||||
}
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
|
||||
|
@ -743,16 +743,16 @@ class MathTrig
|
|||
$summer = 0;
|
||||
$divisor = 1;
|
||||
// Loop through arguments
|
||||
foreach (PHPExcel_Calculation_Functions::flattenArray(func_get_args()) as $arg) {
|
||||
foreach (Functions::flattenArray(func_get_args()) as $arg) {
|
||||
// Is it a numeric value?
|
||||
if (is_numeric($arg)) {
|
||||
if ($arg < 1) {
|
||||
return PHPExcel_Calculation_Functions::NaN();
|
||||
return Functions::NaN();
|
||||
}
|
||||
$summer += floor($arg);
|
||||
$divisor *= self::FACT($arg);
|
||||
} else {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -775,7 +775,7 @@ class MathTrig
|
|||
*/
|
||||
public static function ODD($number)
|
||||
{
|
||||
$number = PHPExcel_Calculation_Functions::flattenSingleValue($number);
|
||||
$number = Functions::flattenSingleValue($number);
|
||||
|
||||
if (is_null($number)) {
|
||||
return 1;
|
||||
|
@ -794,7 +794,7 @@ class MathTrig
|
|||
|
||||
return (int) $result;
|
||||
}
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
|
||||
|
@ -809,19 +809,19 @@ class MathTrig
|
|||
*/
|
||||
public static function POWER($x = 0, $y = 2)
|
||||
{
|
||||
$x = PHPExcel_Calculation_Functions::flattenSingleValue($x);
|
||||
$y = PHPExcel_Calculation_Functions::flattenSingleValue($y);
|
||||
$x = Functions::flattenSingleValue($x);
|
||||
$y = Functions::flattenSingleValue($y);
|
||||
|
||||
// Validate parameters
|
||||
if ($x == 0.0 && $y == 0.0) {
|
||||
return PHPExcel_Calculation_Functions::NaN();
|
||||
return Functions::NaN();
|
||||
} elseif ($x == 0.0 && $y < 0.0) {
|
||||
return PHPExcel_Calculation_Functions::DIV0();
|
||||
return Functions::DIV0();
|
||||
}
|
||||
|
||||
// Return
|
||||
$result = pow($x, $y);
|
||||
return (!is_nan($result) && !is_infinite($result)) ? $result : PHPExcel_Calculation_Functions::NaN();
|
||||
return (!is_nan($result) && !is_infinite($result)) ? $result : Functions::NaN();
|
||||
}
|
||||
|
||||
|
||||
|
@ -844,7 +844,7 @@ class MathTrig
|
|||
$returnValue = null;
|
||||
|
||||
// Loop through arguments
|
||||
foreach (PHPExcel_Calculation_Functions::flattenArray(func_get_args()) as $arg) {
|
||||
foreach (Functions::flattenArray(func_get_args()) as $arg) {
|
||||
// Is it a numeric value?
|
||||
if ((is_numeric($arg)) && (!is_string($arg))) {
|
||||
if (is_null($returnValue)) {
|
||||
|
@ -883,7 +883,7 @@ class MathTrig
|
|||
$returnValue = null;
|
||||
|
||||
// Loop through arguments
|
||||
foreach (PHPExcel_Calculation_Functions::flattenArray(func_get_args()) as $arg) {
|
||||
foreach (Functions::flattenArray(func_get_args()) as $arg) {
|
||||
// Is it a numeric value?
|
||||
if ((is_numeric($arg)) && (!is_string($arg))) {
|
||||
if (is_null($returnValue)) {
|
||||
|
@ -912,8 +912,8 @@ class MathTrig
|
|||
*/
|
||||
public static function RAND($min = 0, $max = 0)
|
||||
{
|
||||
$min = PHPExcel_Calculation_Functions::flattenSingleValue($min);
|
||||
$max = PHPExcel_Calculation_Functions::flattenSingleValue($max);
|
||||
$min = Functions::flattenSingleValue($min);
|
||||
$max = Functions::flattenSingleValue($max);
|
||||
|
||||
if ($min == 0 && $max == 0) {
|
||||
return (mt_rand(0, 10000000)) / 10000000;
|
||||
|
@ -925,10 +925,10 @@ class MathTrig
|
|||
|
||||
public static function ROMAN($aValue, $style = 0)
|
||||
{
|
||||
$aValue = PHPExcel_Calculation_Functions::flattenSingleValue($aValue);
|
||||
$style = (is_null($style)) ? 0 : (integer) PHPExcel_Calculation_Functions::flattenSingleValue($style);
|
||||
$aValue = Functions::flattenSingleValue($aValue);
|
||||
$style = (is_null($style)) ? 0 : (integer) Functions::flattenSingleValue($style);
|
||||
if ((!is_numeric($aValue)) || ($aValue < 0) || ($aValue >= 4000)) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
$aValue = (integer) $aValue;
|
||||
if ($aValue == 0) {
|
||||
|
@ -967,8 +967,8 @@ class MathTrig
|
|||
*/
|
||||
public static function ROUNDUP($number, $digits)
|
||||
{
|
||||
$number = PHPExcel_Calculation_Functions::flattenSingleValue($number);
|
||||
$digits = PHPExcel_Calculation_Functions::flattenSingleValue($digits);
|
||||
$number = Functions::flattenSingleValue($number);
|
||||
$digits = Functions::flattenSingleValue($digits);
|
||||
|
||||
if ((is_numeric($number)) && (is_numeric($digits))) {
|
||||
$significance = pow(10, (int) $digits);
|
||||
|
@ -978,7 +978,7 @@ class MathTrig
|
|||
return ceil($number * $significance) / $significance;
|
||||
}
|
||||
}
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
|
||||
|
@ -993,8 +993,8 @@ class MathTrig
|
|||
*/
|
||||
public static function ROUNDDOWN($number, $digits)
|
||||
{
|
||||
$number = PHPExcel_Calculation_Functions::flattenSingleValue($number);
|
||||
$digits = PHPExcel_Calculation_Functions::flattenSingleValue($digits);
|
||||
$number = Functions::flattenSingleValue($number);
|
||||
$digits = Functions::flattenSingleValue($digits);
|
||||
|
||||
if ((is_numeric($number)) && (is_numeric($digits))) {
|
||||
$significance = pow(10, (int) $digits);
|
||||
|
@ -1004,7 +1004,7 @@ class MathTrig
|
|||
return floor($number * $significance) / $significance;
|
||||
}
|
||||
}
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
|
||||
|
@ -1024,7 +1024,7 @@ class MathTrig
|
|||
$returnValue = 0;
|
||||
|
||||
// Loop through arguments
|
||||
$aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
|
||||
$aArgs = Functions::flattenArray(func_get_args());
|
||||
|
||||
$x = array_shift($aArgs);
|
||||
$n = array_shift($aArgs);
|
||||
|
@ -1038,12 +1038,12 @@ class MathTrig
|
|||
if ((is_numeric($arg)) && (!is_string($arg))) {
|
||||
$returnValue += $arg * pow($x, $n + ($m * $i++));
|
||||
} else {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
}
|
||||
return $returnValue;
|
||||
}
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
|
||||
|
@ -1058,7 +1058,7 @@ class MathTrig
|
|||
*/
|
||||
public static function SIGN($number)
|
||||
{
|
||||
$number = PHPExcel_Calculation_Functions::flattenSingleValue($number);
|
||||
$number = Functions::flattenSingleValue($number);
|
||||
|
||||
if (is_bool($number)) {
|
||||
return (int) $number;
|
||||
|
@ -1069,7 +1069,7 @@ class MathTrig
|
|||
}
|
||||
return $number / abs($number);
|
||||
}
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
|
||||
|
@ -1083,15 +1083,15 @@ class MathTrig
|
|||
*/
|
||||
public static function SQRTPI($number)
|
||||
{
|
||||
$number = PHPExcel_Calculation_Functions::flattenSingleValue($number);
|
||||
$number = Functions::flattenSingleValue($number);
|
||||
|
||||
if (is_numeric($number)) {
|
||||
if ($number < 0) {
|
||||
return PHPExcel_Calculation_Functions::NaN();
|
||||
return Functions::NaN();
|
||||
}
|
||||
return sqrt($number * M_PI) ;
|
||||
}
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
|
||||
|
@ -1107,7 +1107,7 @@ class MathTrig
|
|||
*/
|
||||
public static function SUBTOTAL()
|
||||
{
|
||||
$aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
|
||||
$aArgs = Functions::flattenArray(func_get_args());
|
||||
|
||||
// Calculate
|
||||
$subtotal = array_shift($aArgs);
|
||||
|
@ -1115,30 +1115,30 @@ class MathTrig
|
|||
if ((is_numeric($subtotal)) && (!is_string($subtotal))) {
|
||||
switch ($subtotal) {
|
||||
case 1:
|
||||
return PHPExcel_Calculation_Statistical::AVERAGE($aArgs);
|
||||
return Statistical::AVERAGE($aArgs);
|
||||
case 2:
|
||||
return PHPExcel_Calculation_Statistical::COUNT($aArgs);
|
||||
return Statistical::COUNT($aArgs);
|
||||
case 3:
|
||||
return PHPExcel_Calculation_Statistical::COUNTA($aArgs);
|
||||
return Statistical::COUNTA($aArgs);
|
||||
case 4:
|
||||
return PHPExcel_Calculation_Statistical::MAX($aArgs);
|
||||
return Statistical::MAX($aArgs);
|
||||
case 5:
|
||||
return PHPExcel_Calculation_Statistical::MIN($aArgs);
|
||||
return Statistical::MIN($aArgs);
|
||||
case 6:
|
||||
return self::PRODUCT($aArgs);
|
||||
case 7:
|
||||
return PHPExcel_Calculation_Statistical::STDEV($aArgs);
|
||||
return Statistical::STDEV($aArgs);
|
||||
case 8:
|
||||
return PHPExcel_Calculation_Statistical::STDEVP($aArgs);
|
||||
return Statistical::STDEVP($aArgs);
|
||||
case 9:
|
||||
return self::SUM($aArgs);
|
||||
case 10:
|
||||
return PHPExcel_Calculation_Statistical::VARFunc($aArgs);
|
||||
return Statistical::VARFunc($aArgs);
|
||||
case 11:
|
||||
return PHPExcel_Calculation_Statistical::VARP($aArgs);
|
||||
return Statistical::VARP($aArgs);
|
||||
}
|
||||
}
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
|
||||
|
@ -1160,7 +1160,7 @@ class MathTrig
|
|||
$returnValue = 0;
|
||||
|
||||
// Loop through the arguments
|
||||
foreach (PHPExcel_Calculation_Functions::flattenArray(func_get_args()) as $arg) {
|
||||
foreach (Functions::flattenArray(func_get_args()) as $arg) {
|
||||
// Is it a numeric value?
|
||||
if ((is_numeric($arg)) && (!is_string($arg))) {
|
||||
$returnValue += $arg;
|
||||
|
@ -1189,12 +1189,12 @@ class MathTrig
|
|||
{
|
||||
$returnValue = 0;
|
||||
|
||||
$aArgs = PHPExcel_Calculation_Functions::flattenArray($aArgs);
|
||||
$sumArgs = PHPExcel_Calculation_Functions::flattenArray($sumArgs);
|
||||
$aArgs = Functions::flattenArray($aArgs);
|
||||
$sumArgs = Functions::flattenArray($sumArgs);
|
||||
if (empty($sumArgs)) {
|
||||
$sumArgs = $aArgs;
|
||||
}
|
||||
$condition = PHPExcel_Calculation_Functions::ifCondition($condition);
|
||||
$condition = Functions::ifCondition($condition);
|
||||
// Loop through arguments
|
||||
foreach ($aArgs as $key => $arg) {
|
||||
if (!is_numeric($arg)) {
|
||||
|
@ -1228,7 +1228,7 @@ class MathTrig
|
|||
{
|
||||
$arrayList = func_get_args();
|
||||
|
||||
$wrkArray = PHPExcel_Calculation_Functions::flattenArray(array_shift($arrayList));
|
||||
$wrkArray = Functions::flattenArray(array_shift($arrayList));
|
||||
$wrkCellCount = count($wrkArray);
|
||||
|
||||
for ($i=0; $i< $wrkCellCount; ++$i) {
|
||||
|
@ -1238,10 +1238,10 @@ class MathTrig
|
|||
}
|
||||
|
||||
foreach ($arrayList as $matrixData) {
|
||||
$array2 = PHPExcel_Calculation_Functions::flattenArray($matrixData);
|
||||
$array2 = Functions::flattenArray($matrixData);
|
||||
$count = count($array2);
|
||||
if ($wrkCellCount != $count) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
foreach ($array2 as $i => $val) {
|
||||
|
@ -1274,7 +1274,7 @@ class MathTrig
|
|||
$returnValue = 0;
|
||||
|
||||
// Loop through arguments
|
||||
foreach (PHPExcel_Calculation_Functions::flattenArray(func_get_args()) as $arg) {
|
||||
foreach (Functions::flattenArray(func_get_args()) as $arg) {
|
||||
// Is it a numeric value?
|
||||
if ((is_numeric($arg)) && (!is_string($arg))) {
|
||||
$returnValue += ($arg * $arg);
|
||||
|
@ -1294,8 +1294,8 @@ class MathTrig
|
|||
*/
|
||||
public static function SUMX2MY2($matrixData1, $matrixData2)
|
||||
{
|
||||
$array1 = PHPExcel_Calculation_Functions::flattenArray($matrixData1);
|
||||
$array2 = PHPExcel_Calculation_Functions::flattenArray($matrixData2);
|
||||
$array1 = Functions::flattenArray($matrixData1);
|
||||
$array2 = Functions::flattenArray($matrixData2);
|
||||
$count = min(count($array1), count($array2));
|
||||
|
||||
$result = 0;
|
||||
|
@ -1319,8 +1319,8 @@ class MathTrig
|
|||
*/
|
||||
public static function SUMX2PY2($matrixData1, $matrixData2)
|
||||
{
|
||||
$array1 = PHPExcel_Calculation_Functions::flattenArray($matrixData1);
|
||||
$array2 = PHPExcel_Calculation_Functions::flattenArray($matrixData2);
|
||||
$array1 = Functions::flattenArray($matrixData1);
|
||||
$array2 = Functions::flattenArray($matrixData2);
|
||||
$count = min(count($array1), count($array2));
|
||||
|
||||
$result = 0;
|
||||
|
@ -1344,8 +1344,8 @@ class MathTrig
|
|||
*/
|
||||
public static function SUMXMY2($matrixData1, $matrixData2)
|
||||
{
|
||||
$array1 = PHPExcel_Calculation_Functions::flattenArray($matrixData1);
|
||||
$array2 = PHPExcel_Calculation_Functions::flattenArray($matrixData2);
|
||||
$array1 = Functions::flattenArray($matrixData1);
|
||||
$array2 = Functions::flattenArray($matrixData2);
|
||||
$count = min(count($array1), count($array2));
|
||||
|
||||
$result = 0;
|
||||
|
@ -1371,12 +1371,12 @@ class MathTrig
|
|||
*/
|
||||
public static function TRUNC($value = 0, $digits = 0)
|
||||
{
|
||||
$value = PHPExcel_Calculation_Functions::flattenSingleValue($value);
|
||||
$digits = PHPExcel_Calculation_Functions::flattenSingleValue($digits);
|
||||
$value = Functions::flattenSingleValue($value);
|
||||
$digits = Functions::flattenSingleValue($digits);
|
||||
|
||||
// Validate parameters
|
||||
if ((!is_numeric($value)) || (!is_numeric($digits))) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
$digits = floor($digits);
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -47,7 +47,7 @@ class TextData
|
|||
return (ord($c{0})-252)*1073741824 + (ord($c{1})-128)*16777216 + (ord($c{2})-128)*262144 + (ord($c{3})-128)*4096 + (ord($c{4})-128)*64 + (ord($c{5})-128);
|
||||
} elseif (ord($c{0}) >= 254 && ord($c{0}) <= 255) {
|
||||
// error
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -60,10 +60,10 @@ class TextData
|
|||
*/
|
||||
public static function CHARACTER($character)
|
||||
{
|
||||
$character = PHPExcel_Calculation_Functions::flattenSingleValue($character);
|
||||
$character = Functions::flattenSingleValue($character);
|
||||
|
||||
if ((!is_numeric($character)) || ($character < 0)) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
if (function_exists('mb_convert_encoding')) {
|
||||
|
@ -82,7 +82,7 @@ class TextData
|
|||
*/
|
||||
public static function TRIMNONPRINTABLE($stringValue = '')
|
||||
{
|
||||
$stringValue = PHPExcel_Calculation_Functions::flattenSingleValue($stringValue);
|
||||
$stringValue = Functions::flattenSingleValue($stringValue);
|
||||
|
||||
if (is_bool($stringValue)) {
|
||||
return ($stringValue) ? PHPExcel_Calculation::getTRUE() : PHPExcel_Calculation::getFALSE();
|
||||
|
@ -107,7 +107,7 @@ class TextData
|
|||
*/
|
||||
public static function TRIMSPACES($stringValue = '')
|
||||
{
|
||||
$stringValue = PHPExcel_Calculation_Functions::flattenSingleValue($stringValue);
|
||||
$stringValue = Functions::flattenSingleValue($stringValue);
|
||||
if (is_bool($stringValue)) {
|
||||
return ($stringValue) ? PHPExcel_Calculation::getTRUE() : PHPExcel_Calculation::getFALSE();
|
||||
}
|
||||
|
@ -128,11 +128,11 @@ class TextData
|
|||
public static function ASCIICODE($characters)
|
||||
{
|
||||
if (($characters === null) || ($characters === '')) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
$characters = PHPExcel_Calculation_Functions::flattenSingleValue($characters);
|
||||
$characters = Functions::flattenSingleValue($characters);
|
||||
if (is_bool($characters)) {
|
||||
if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE) {
|
||||
if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_OPENOFFICE) {
|
||||
$characters = (int) $characters;
|
||||
} else {
|
||||
$characters = ($characters) ? PHPExcel_Calculation::getTRUE() : PHPExcel_Calculation::getFALSE();
|
||||
|
@ -164,10 +164,10 @@ class TextData
|
|||
$returnValue = '';
|
||||
|
||||
// Loop through arguments
|
||||
$aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
|
||||
$aArgs = Functions::flattenArray(func_get_args());
|
||||
foreach ($aArgs as $arg) {
|
||||
if (is_bool($arg)) {
|
||||
if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE) {
|
||||
if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_OPENOFFICE) {
|
||||
$arg = (int) $arg;
|
||||
} else {
|
||||
$arg = ($arg) ? PHPExcel_Calculation::getTRUE() : PHPExcel_Calculation::getFALSE();
|
||||
|
@ -194,12 +194,12 @@ class TextData
|
|||
*/
|
||||
public static function DOLLAR($value = 0, $decimals = 2)
|
||||
{
|
||||
$value = PHPExcel_Calculation_Functions::flattenSingleValue($value);
|
||||
$decimals = is_null($decimals) ? 0 : PHPExcel_Calculation_Functions::flattenSingleValue($decimals);
|
||||
$value = Functions::flattenSingleValue($value);
|
||||
$decimals = is_null($decimals) ? 0 : Functions::flattenSingleValue($decimals);
|
||||
|
||||
// Validate parameters
|
||||
if (!is_numeric($value) || !is_numeric($decimals)) {
|
||||
return PHPExcel_Calculation_Functions::NaN();
|
||||
return Functions::NaN();
|
||||
}
|
||||
$decimals = floor($decimals);
|
||||
|
||||
|
@ -211,7 +211,7 @@ class TextData
|
|||
if ($value < 0) {
|
||||
$round = 0-$round;
|
||||
}
|
||||
$value = PHPExcel_Calculation_MathTrig::MROUND($value, $round);
|
||||
$value = MathTrig::MROUND($value, $round);
|
||||
}
|
||||
|
||||
return PHPExcel_Style_NumberFormat::toFormattedString($value, $mask);
|
||||
|
@ -229,9 +229,9 @@ class TextData
|
|||
*/
|
||||
public static function SEARCHSENSITIVE($needle, $haystack, $offset = 1)
|
||||
{
|
||||
$needle = PHPExcel_Calculation_Functions::flattenSingleValue($needle);
|
||||
$haystack = PHPExcel_Calculation_Functions::flattenSingleValue($haystack);
|
||||
$offset = PHPExcel_Calculation_Functions::flattenSingleValue($offset);
|
||||
$needle = Functions::flattenSingleValue($needle);
|
||||
$haystack = Functions::flattenSingleValue($haystack);
|
||||
$offset = Functions::flattenSingleValue($offset);
|
||||
|
||||
if (!is_bool($needle)) {
|
||||
if (is_bool($haystack)) {
|
||||
|
@ -252,7 +252,7 @@ class TextData
|
|||
}
|
||||
}
|
||||
}
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
|
||||
|
@ -266,9 +266,9 @@ class TextData
|
|||
*/
|
||||
public static function SEARCHINSENSITIVE($needle, $haystack, $offset = 1)
|
||||
{
|
||||
$needle = PHPExcel_Calculation_Functions::flattenSingleValue($needle);
|
||||
$haystack = PHPExcel_Calculation_Functions::flattenSingleValue($haystack);
|
||||
$offset = PHPExcel_Calculation_Functions::flattenSingleValue($offset);
|
||||
$needle = Functions::flattenSingleValue($needle);
|
||||
$haystack = Functions::flattenSingleValue($haystack);
|
||||
$offset = Functions::flattenSingleValue($offset);
|
||||
|
||||
if (!is_bool($needle)) {
|
||||
if (is_bool($haystack)) {
|
||||
|
@ -289,7 +289,7 @@ class TextData
|
|||
}
|
||||
}
|
||||
}
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
|
||||
|
@ -303,13 +303,13 @@ class TextData
|
|||
*/
|
||||
public static function FIXEDFORMAT($value, $decimals = 2, $no_commas = false)
|
||||
{
|
||||
$value = PHPExcel_Calculation_Functions::flattenSingleValue($value);
|
||||
$decimals = PHPExcel_Calculation_Functions::flattenSingleValue($decimals);
|
||||
$no_commas = PHPExcel_Calculation_Functions::flattenSingleValue($no_commas);
|
||||
$value = Functions::flattenSingleValue($value);
|
||||
$decimals = Functions::flattenSingleValue($decimals);
|
||||
$no_commas = Functions::flattenSingleValue($no_commas);
|
||||
|
||||
// Validate parameters
|
||||
if (!is_numeric($value) || !is_numeric($decimals)) {
|
||||
return PHPExcel_Calculation_Functions::NaN();
|
||||
return Functions::NaN();
|
||||
}
|
||||
$decimals = floor($decimals);
|
||||
|
||||
|
@ -334,11 +334,11 @@ class TextData
|
|||
*/
|
||||
public static function LEFT($value = '', $chars = 1)
|
||||
{
|
||||
$value = PHPExcel_Calculation_Functions::flattenSingleValue($value);
|
||||
$chars = PHPExcel_Calculation_Functions::flattenSingleValue($chars);
|
||||
$value = Functions::flattenSingleValue($value);
|
||||
$chars = Functions::flattenSingleValue($chars);
|
||||
|
||||
if ($chars < 0) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
if (is_bool($value)) {
|
||||
|
@ -363,12 +363,12 @@ class TextData
|
|||
*/
|
||||
public static function MID($value = '', $start = 1, $chars = null)
|
||||
{
|
||||
$value = PHPExcel_Calculation_Functions::flattenSingleValue($value);
|
||||
$start = PHPExcel_Calculation_Functions::flattenSingleValue($start);
|
||||
$chars = PHPExcel_Calculation_Functions::flattenSingleValue($chars);
|
||||
$value = Functions::flattenSingleValue($value);
|
||||
$start = Functions::flattenSingleValue($start);
|
||||
$chars = Functions::flattenSingleValue($chars);
|
||||
|
||||
if (($start < 1) || ($chars < 0)) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
if (is_bool($value)) {
|
||||
|
@ -392,11 +392,11 @@ class TextData
|
|||
*/
|
||||
public static function RIGHT($value = '', $chars = 1)
|
||||
{
|
||||
$value = PHPExcel_Calculation_Functions::flattenSingleValue($value);
|
||||
$chars = PHPExcel_Calculation_Functions::flattenSingleValue($chars);
|
||||
$value = Functions::flattenSingleValue($value);
|
||||
$chars = Functions::flattenSingleValue($chars);
|
||||
|
||||
if ($chars < 0) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
|
||||
if (is_bool($value)) {
|
||||
|
@ -419,7 +419,7 @@ class TextData
|
|||
*/
|
||||
public static function STRINGLENGTH($value = '')
|
||||
{
|
||||
$value = PHPExcel_Calculation_Functions::flattenSingleValue($value);
|
||||
$value = Functions::flattenSingleValue($value);
|
||||
|
||||
if (is_bool($value)) {
|
||||
$value = ($value) ? PHPExcel_Calculation::getTRUE() : PHPExcel_Calculation::getFALSE();
|
||||
|
@ -443,7 +443,7 @@ class TextData
|
|||
*/
|
||||
public static function LOWERCASE($mixedCaseString)
|
||||
{
|
||||
$mixedCaseString = PHPExcel_Calculation_Functions::flattenSingleValue($mixedCaseString);
|
||||
$mixedCaseString = Functions::flattenSingleValue($mixedCaseString);
|
||||
|
||||
if (is_bool($mixedCaseString)) {
|
||||
$mixedCaseString = ($mixedCaseString) ? PHPExcel_Calculation::getTRUE() : PHPExcel_Calculation::getFALSE();
|
||||
|
@ -463,7 +463,7 @@ class TextData
|
|||
*/
|
||||
public static function UPPERCASE($mixedCaseString)
|
||||
{
|
||||
$mixedCaseString = PHPExcel_Calculation_Functions::flattenSingleValue($mixedCaseString);
|
||||
$mixedCaseString = Functions::flattenSingleValue($mixedCaseString);
|
||||
|
||||
if (is_bool($mixedCaseString)) {
|
||||
$mixedCaseString = ($mixedCaseString) ? PHPExcel_Calculation::getTRUE() : PHPExcel_Calculation::getFALSE();
|
||||
|
@ -483,7 +483,7 @@ class TextData
|
|||
*/
|
||||
public static function PROPERCASE($mixedCaseString)
|
||||
{
|
||||
$mixedCaseString = PHPExcel_Calculation_Functions::flattenSingleValue($mixedCaseString);
|
||||
$mixedCaseString = Functions::flattenSingleValue($mixedCaseString);
|
||||
|
||||
if (is_bool($mixedCaseString)) {
|
||||
$mixedCaseString = ($mixedCaseString) ? PHPExcel_Calculation::getTRUE() : PHPExcel_Calculation::getFALSE();
|
||||
|
@ -504,10 +504,10 @@ class TextData
|
|||
*/
|
||||
public static function REPLACE($oldText = '', $start = 1, $chars = null, $newText)
|
||||
{
|
||||
$oldText = PHPExcel_Calculation_Functions::flattenSingleValue($oldText);
|
||||
$start = PHPExcel_Calculation_Functions::flattenSingleValue($start);
|
||||
$chars = PHPExcel_Calculation_Functions::flattenSingleValue($chars);
|
||||
$newText = PHPExcel_Calculation_Functions::flattenSingleValue($newText);
|
||||
$oldText = Functions::flattenSingleValue($oldText);
|
||||
$start = Functions::flattenSingleValue($start);
|
||||
$chars = Functions::flattenSingleValue($chars);
|
||||
$newText = Functions::flattenSingleValue($newText);
|
||||
|
||||
$left = self::LEFT($oldText, $start-1);
|
||||
$right = self::RIGHT($oldText, self::STRINGLENGTH($oldText)-($start+$chars)+1);
|
||||
|
@ -527,10 +527,10 @@ class TextData
|
|||
*/
|
||||
public static function SUBSTITUTE($text = '', $fromText = '', $toText = '', $instance = 0)
|
||||
{
|
||||
$text = PHPExcel_Calculation_Functions::flattenSingleValue($text);
|
||||
$fromText = PHPExcel_Calculation_Functions::flattenSingleValue($fromText);
|
||||
$toText = PHPExcel_Calculation_Functions::flattenSingleValue($toText);
|
||||
$instance = floor(PHPExcel_Calculation_Functions::flattenSingleValue($instance));
|
||||
$text = Functions::flattenSingleValue($text);
|
||||
$fromText = Functions::flattenSingleValue($fromText);
|
||||
$toText = Functions::flattenSingleValue($toText);
|
||||
$instance = floor(Functions::flattenSingleValue($instance));
|
||||
|
||||
if ($instance == 0) {
|
||||
if (function_exists('mb_str_replace')) {
|
||||
|
@ -572,7 +572,7 @@ class TextData
|
|||
*/
|
||||
public static function RETURNSTRING($testValue = '')
|
||||
{
|
||||
$testValue = PHPExcel_Calculation_Functions::flattenSingleValue($testValue);
|
||||
$testValue = Functions::flattenSingleValue($testValue);
|
||||
|
||||
if (is_string($testValue)) {
|
||||
return $testValue;
|
||||
|
@ -590,11 +590,11 @@ class TextData
|
|||
*/
|
||||
public static function TEXTFORMAT($value, $format)
|
||||
{
|
||||
$value = PHPExcel_Calculation_Functions::flattenSingleValue($value);
|
||||
$format = PHPExcel_Calculation_Functions::flattenSingleValue($format);
|
||||
$value = Functions::flattenSingleValue($value);
|
||||
$format = Functions::flattenSingleValue($format);
|
||||
|
||||
if ((is_string($value)) && (!is_numeric($value)) && PHPExcel_Shared_Date::isDateTimeFormatCode($format)) {
|
||||
$value = PHPExcel_Calculation_DateTime::DATEVALUE($value);
|
||||
$value = DateTime::DATEVALUE($value);
|
||||
}
|
||||
|
||||
return (string) PHPExcel_Style_NumberFormat::toFormattedString($value, $format);
|
||||
|
@ -608,7 +608,7 @@ class TextData
|
|||
*/
|
||||
public static function VALUE($value = '')
|
||||
{
|
||||
$value = PHPExcel_Calculation_Functions::flattenSingleValue($value);
|
||||
$value = Functions::flattenSingleValue($value);
|
||||
|
||||
if (!is_numeric($value)) {
|
||||
$numberValue = str_replace(
|
||||
|
@ -620,24 +620,24 @@ class TextData
|
|||
return (float) $numberValue;
|
||||
}
|
||||
|
||||
$dateSetting = PHPExcel_Calculation_Functions::getReturnDateType();
|
||||
PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL);
|
||||
$dateSetting = Functions::getReturnDateType();
|
||||
Functions::setReturnDateType(Functions::RETURNDATE_EXCEL);
|
||||
|
||||
if (strpos($value, ':') !== false) {
|
||||
$timeValue = PHPExcel_Calculation_DateTime::TIMEVALUE($value);
|
||||
if ($timeValue !== PHPExcel_Calculation_Functions::VALUE()) {
|
||||
PHPExcel_Calculation_Functions::setReturnDateType($dateSetting);
|
||||
$timeValue = DateTime::TIMEVALUE($value);
|
||||
if ($timeValue !== Functions::VALUE()) {
|
||||
Functions::setReturnDateType($dateSetting);
|
||||
return $timeValue;
|
||||
}
|
||||
}
|
||||
$dateValue = PHPExcel_Calculation_DateTime::DATEVALUE($value);
|
||||
if ($dateValue !== PHPExcel_Calculation_Functions::VALUE()) {
|
||||
PHPExcel_Calculation_Functions::setReturnDateType($dateSetting);
|
||||
$dateValue = DateTime::DATEVALUE($value);
|
||||
if ($dateValue !== Functions::VALUE()) {
|
||||
Functions::setReturnDateType($dateSetting);
|
||||
return $dateValue;
|
||||
}
|
||||
PHPExcel_Calculation_Functions::setReturnDateType($dateSetting);
|
||||
Functions::setReturnDateType($dateSetting);
|
||||
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
return Functions::VALUE();
|
||||
}
|
||||
return (float) $value;
|
||||
}
|
||||
|
|
|
@ -1,54 +0,0 @@
|
|||
<?php
|
||||
|
||||
|
||||
class AutoloaderTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
define('PHPEXCEL_ROOT', APPLICATION_PATH . '/');
|
||||
}
|
||||
require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||
}
|
||||
|
||||
public function testAutoloaderNonPHPExcelClass()
|
||||
{
|
||||
$className = 'InvalidClass';
|
||||
|
||||
$result = PHPExcel_Autoloader::Load($className);
|
||||
// Must return a boolean...
|
||||
$this->assertTrue(is_bool($result));
|
||||
// ... indicating failure
|
||||
$this->assertFalse($result);
|
||||
}
|
||||
|
||||
public function testAutoloaderInvalidPHPExcelClass()
|
||||
{
|
||||
$className = 'PHPExcel_Invalid_Class';
|
||||
|
||||
$result = PHPExcel_Autoloader::Load($className);
|
||||
// Must return a boolean...
|
||||
$this->assertTrue(is_bool($result));
|
||||
// ... indicating failure
|
||||
$this->assertFalse($result);
|
||||
}
|
||||
|
||||
public function testAutoloadValidPHPExcelClass()
|
||||
{
|
||||
$className = 'PHPExcel_IOFactory';
|
||||
|
||||
$result = PHPExcel_Autoloader::Load($className);
|
||||
// Check that class has been loaded
|
||||
$this->assertTrue(class_exists($className));
|
||||
}
|
||||
|
||||
public function testAutoloadInstantiateSuccess()
|
||||
{
|
||||
$result = new PHPExcel_Calculation_Function(1, 2, 3);
|
||||
// Must return an object...
|
||||
$this->assertTrue(is_object($result));
|
||||
// ... of the correct type
|
||||
$this->assertTrue(is_a($result, 'PHPExcel_Calculation_Function'));
|
||||
}
|
||||
}
|
|
@ -7,19 +7,19 @@ class AdvancedValueBinderTest extends PHPUnit_Framework_TestCase
|
|||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
define('PHPEXCEL_ROOT', APPLICATION_PATH . '/');
|
||||
}
|
||||
require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||
require_once(PHPEXCEL_ROOT . '/Bootstrap.php');
|
||||
}
|
||||
|
||||
public function provider()
|
||||
{
|
||||
if (!class_exists('PHPExcel_Style_NumberFormat')) {
|
||||
if (!class_exists('\\PHPExcel\\Style\\NumberFormat')) {
|
||||
$this->setUp();
|
||||
}
|
||||
$currencyUSD = PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE;
|
||||
$currencyEURO = str_replace('$', '€', PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE);
|
||||
$currencyUSD = \PHPExcel\Style\NumberFormat::FORMAT_CURRENCY_USD_SIMPLE;
|
||||
$currencyEURO = str_replace('$', '€', \PHPExcel\Style\NumberFormat::FORMAT_CURRENCY_USD_SIMPLE);
|
||||
|
||||
return array(
|
||||
array('10%', 0.1, PHPExcel_Style_NumberFormat::FORMAT_PERCENTAGE_00, ',', '.', '$'),
|
||||
array('10%', 0.1, \PHPExcel\Style\NumberFormat::FORMAT_PERCENTAGE_00, ',', '.', '$'),
|
||||
array('$10.11', 10.11, $currencyUSD, ',', '.', '$'),
|
||||
array('$1,010.12', 1010.12, $currencyUSD, ',', '.', '$'),
|
||||
array('$20,20', 20.2, $currencyUSD, '.', ',', '$'),
|
|
@ -17,7 +17,7 @@ date_default_timezone_set('Europe/London');
|
|||
|
||||
// Define path to application directory
|
||||
defined('APPLICATION_PATH')
|
||||
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../Classes'));
|
||||
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../classes'));
|
||||
|
||||
// Define path to application tests directory
|
||||
defined('APPLICATION_TESTS_PATH')
|
||||
|
@ -28,7 +28,7 @@ defined('APPLICATION_ENV') || define('APPLICATION_ENV', 'ci');
|
|||
|
||||
// Ensure library/ is on include_path
|
||||
set_include_path(implode(PATH_SEPARATOR, array(
|
||||
realpath(APPLICATION_PATH . '/../Classes'),
|
||||
realpath(APPLICATION_PATH . '/../classes'),
|
||||
'./',
|
||||
dirname(__FILE__),
|
||||
get_include_path(),
|
||||
|
|
|
@ -17,15 +17,15 @@
|
|||
<ini name="memory_limit" value="2048M"/>
|
||||
</php>
|
||||
<testsuite name="PHPExcel Unit Test Suite">
|
||||
<directory suffix="Test.php">./Classes</directory>
|
||||
<directory suffix="Test.php">./classes</directory>
|
||||
</testsuite>
|
||||
<filter>
|
||||
<whitelist>
|
||||
<directory suffix=".php">../Classes</directory>
|
||||
<directory suffix=".php">../classes</directory>
|
||||
<exclude>
|
||||
<directory>../Classes/PHPExcel/Shared/PCLZip</directory>
|
||||
<directory>../Classes/PHPExcel/Shared/JAMA</directory>
|
||||
<directory>../Classes/PHPExcel/Writer/PDF</directory>
|
||||
<directory>../classes/src/Shared/PCLZip</directory>
|
||||
<directory>../classes/src/Shared/JAMA</directory>
|
||||
<directory>../classes/src/Writer/PDF</directory>
|
||||
</exclude>
|
||||
</whitelist>
|
||||
</filter>
|
||||
|
|
|
@ -17,15 +17,15 @@
|
|||
<ini name="memory_limit" value="2048M"/>
|
||||
</php>
|
||||
<testsuite name="PHPExcel Unit Test Suite">
|
||||
<directory suffix="Test.php">./Classes</directory>
|
||||
<directory suffix="Test.php">./classes</directory>
|
||||
</testsuite>
|
||||
<filter>
|
||||
<whitelist>
|
||||
<directory suffix=".php">../Classes</directory>
|
||||
<directory suffix=".php">../classes</directory>
|
||||
<exclude>
|
||||
<directory>../Classes/PHPExcel/Shared/PCLZip</directory>
|
||||
<directory>../Classes/PHPExcel/Shared/JAMA</directory>
|
||||
<directory>../Classes/PHPExcel/Writer/PDF</directory>
|
||||
<directory>../classes/src/Shared/PCLZip</directory>
|
||||
<directory>../classes/src/Shared/JAMA</directory>
|
||||
<directory>../classes/src/Writer/PDF</directory>
|
||||
</exclude>
|
||||
</whitelist>
|
||||
</filter>
|
||||
|
|
Loading…
Reference in New Issue