30 if (!
defined(
'PHPEXCEL_ROOT')) {
34 define(
'PHPEXCEL_ROOT', dirname(__FILE__) .
'/../../');
35 require(PHPEXCEL_ROOT .
'PHPExcel/Autoloader.php');
40 define(
'MAX_VALUE', 1.2e308);
43 define(
'M_2DIVPI', 0.63661977236758134307553505349006);
46 define(
'MAX_ITERATIONS', 256);
49 define(
'PRECISION', 8.88E-016);
94 'divisionbyzero' =>
'#DIV/0!',
96 'reference' =>
'#REF!',
100 'gettingdata' =>
'#GETTING_DATA' 139 return self::$compatibilityMode;
156 if (($returnDateType == self::RETURNDATE_PHP_NUMERIC) ||
157 ($returnDateType == self::RETURNDATE_PHP_OBJECT) ||
158 ($returnDateType == self::RETURNDATE_EXCEL)) {
159 self::$ReturnDateType = $returnDateType;
178 return self::$ReturnDateType;
190 return '#Not Yet Implemented';
201 public static function DIV0() {
202 return self::$_errorCodes[
'divisionbyzero'];
219 public static function NA() {
220 return self::$_errorCodes[
'na'];
233 public static function NaN() {
234 return self::$_errorCodes[
'num'];
247 public static function NAME() {
248 return self::$_errorCodes[
'name'];
261 public static function REF() {
262 return self::$_errorCodes[
'reference'];
275 public static function NULL() {
276 return self::$_errorCodes[
'null'];
290 return self::$_errorCodes[
'value'];
295 return ((substr_count($idx,
'.') <= 1) || (preg_match(
'/\.[A-Z]/',$idx) > 0));
300 return (substr_count($idx,
'.') == 0);
305 return (substr_count($idx,
'.') > 1);
311 if (!isset($condition{0}))
313 if (!in_array($condition{0},
array(
'>',
'<',
'='))) {
315 return '='.$condition;
317 preg_match(
'/([<>=]+)(.*)/',$condition,$matches);
318 list(,$operator,$operand) = $matches;
320 if (!is_numeric($operand)) {
321 $operand = str_replace(
'"',
'""', $operand);
325 return $operator.$operand;
337 $value = self::flattenSingleValue($value);
341 if ($value === $errorCode) {
357 if (!is_null($value)) {
358 $value = self::flattenSingleValue($value);
361 return is_null($value);
371 public static function IS_ERR($value =
'') {
372 $value = self::flattenSingleValue($value);
374 return self::IS_ERROR($value) && (!self::IS_NA($value));
385 $value = self::flattenSingleValue($value);
387 if (!is_string($value))
389 return in_array($value, array_values(self::$_errorCodes));
399 public static function IS_NA($value =
'') {
400 $value = self::flattenSingleValue($value);
402 return ($value === self::NA());
413 $value = self::flattenSingleValue($value);
417 if ((is_bool($value)) || ((is_string($value)) && (!is_numeric($value))))
418 return self::VALUE();
419 return ($value % 2 == 0);
430 $value = self::flattenSingleValue($value);
434 if ((is_bool($value)) || ((is_string($value)) && (!is_numeric($value))))
435 return self::VALUE();
436 return (abs($value) % 2 == 1);
447 $value = self::flattenSingleValue($value);
449 if (is_string($value)) {
452 return is_numeric($value);
463 $value = self::flattenSingleValue($value);
465 return is_bool($value);
476 $value = self::flattenSingleValue($value);
478 return (is_string($value) && !self::IS_ERROR($value));
489 return !self::IS_TEXT($value);
499 return 'PHPExcel 1.8.1, 2015-04-30';
518 public static function N($value =
NULL) {
519 while (is_array($value)) {
520 $value = array_shift($value);
523 switch (gettype($value)) {
530 return (integer) $value;
534 if ((strlen($value) > 0) && ($value{0} ==
'#')) {
558 $value = self::flattenArrayIndexed($value);
559 if (is_array($value) && (count($value) > 1)) {
560 $a = array_keys($value);
563 if (self::isCellValue($a)) {
566 } elseif (self::isMatrixValue($a)) {
569 } elseif(empty($value)) {
573 $value = self::flattenSingleValue($value);
575 if (($value ===
NULL) || (is_float($value)) || (is_int($value))) {
577 } elseif(is_bool($value)) {
579 } elseif(is_array($value)) {
581 } elseif(is_string($value)) {
583 if ((strlen($value) > 0) && ($value{0} ==
'#')) {
599 if (!is_array($array)) {
600 return (
array) $array;
603 $arrayValues =
array();
604 foreach ($array as $value) {
605 if (is_array($value)) {
606 foreach ($value as $val) {
607 if (is_array($val)) {
608 foreach ($val as $v) {
612 $arrayValues[] = $val;
616 $arrayValues[] = $value;
631 if (!is_array($array)) {
632 return (
array) $array;
635 $arrayValues =
array();
636 foreach ($array as $k1 => $value) {
637 if (is_array($value)) {
638 foreach ($value as $k2 => $val) {
639 if (is_array($val)) {
640 foreach ($val as $k3 => $v) {
641 $arrayValues[$k1.
'.'.$k2.
'.'.$k3] = $v;
644 $arrayValues[$k1.
'.'.$k2] = $val;
648 $arrayValues[$k1] = $value;
663 while (is_array($value)) {
664 $value = array_pop($value);
678 if (!function_exists(
'acosh')) {
680 return 2 * log(sqrt((
$x + 1) / 2) + sqrt((
$x - 1) / 2));
684 if (!function_exists(
'asinh')) {
686 return log(
$x + sqrt(1 +
$x *
$x));
690 if (!function_exists(
'atanh')) {
692 return (log(1 +
$x) - log(1 -
$x)) / 2;
701 if ((!function_exists(
'mb_str_replace')) &&
702 (function_exists(
'mb_substr')) && (function_exists(
'mb_strlen')) && (function_exists(
'mb_strpos'))) {
703 function mb_str_replace($search, $replace, $subject) {
704 if(is_array($subject)) {
706 foreach($subject as
$key => $val) {
707 $ret[
$key] = mb_str_replace($search, $replace, $val);
713 if(
$s ==
'' &&
$s !== 0) {
716 $r = !is_array($replace) ? $replace : (array_key_exists(
$key, $replace) ? $replace[
$key] :
'');
717 $pos = mb_strpos($subject,
$s, 0,
'UTF-8');
718 while($pos !==
false) {
719 $subject = mb_substr($subject, 0, $pos,
'UTF-8') .
$r . mb_substr($subject, $pos + mb_strlen(
$s,
'UTF-8'), 65535,
'UTF-8');
720 $pos = mb_strpos($subject,
$s, $pos + mb_strlen(
$r,
'UTF-8'),
'UTF-8');
const RETURNDATE_PHP_OBJECT
static IS_ERROR($value='')
IS_ERROR.
static flattenSingleValue($value='')
Convert an array to a single scalar value by extracting the first element.
static IS_ODD($value=NULL)
IS_ODD.
static TYPE($value=NULL)
TYPE.
static IS_NUMBER($value=NULL)
IS_NUMBER.
const COMPATIBILITY_EXCEL
constants
static _wrapResult($value)
Wrap string values in quotes.
static $compatibilityMode
static ERROR_TYPE($value='')
ERROR_TYPE.
static flattenArray($array)
Convert a multi-dimensional array to a simple 1-dimensional array.
static IS_TEXT($value=NULL)
IS_TEXT.
static IS_LOGICAL($value=NULL)
IS_LOGICAL.
static flattenArrayIndexed($array)
Convert a multi-dimensional array to a simple 1-dimensional array, but retain an element of indexing...
const RETURNDATE_PHP_NUMERIC
static _ifCondition($condition)
static IS_ERR($value='')
IS_ERR.
static isMatrixValue($idx)
static IS_BLANK($value=NULL)
IS_BLANK.
static getReturnDateType()
const COMPATIBILITY_OPENOFFICE
static IS_EVEN($value=NULL)
IS_EVEN.
Create styles array
The data for the language used.
static getCompatibilityMode()
static setReturnDateType($returnDateType)
const COMPATIBILITY_GNUMERIC
static IS_NONTEXT($value=NULL)
IS_NONTEXT.
defined( 'APPLICATION_ENV')||define( 'APPLICATION_ENV'
static IS_NA($value='')
IS_NA.
static setCompatibilityMode($compatibilityMode)