30 if (!
defined(
'PHPEXCEL_ROOT')) {
34 define(
'PHPEXCEL_ROOT', dirname(__FILE__) .
'/../../');
35 require(PHPEXCEL_ROOT .
'PHPExcel/Autoloader.php');
51 if (ord($c{0}) >=0 && ord($c{0}) <= 127)
53 if (ord($c{0}) >= 192 && ord($c{0}) <= 223)
54 return (ord($c{0})-192)*64 + (ord($c{1})-128);
55 if (ord($c{0}) >= 224 && ord($c{0}) <= 239)
56 return (ord($c{0})-224)*4096 + (ord($c{1})-128)*64 + (ord($c{2})-128);
57 if (ord($c{0}) >= 240 && ord($c{0}) <= 247)
58 return (ord($c{0})-240)*262144 + (ord($c{1})-128)*4096 + (ord($c{2})-128)*64 + (ord($c{3})-128);
59 if (ord($c{0}) >= 248 && ord($c{0}) <= 251)
60 return (ord($c{0})-248)*16777216 + (ord($c{1})-128)*262144 + (ord($c{2})-128)*4096 + (ord($c{3})-128)*64 + (ord($c{4})-128);
61 if (ord($c{0}) >= 252 && ord($c{0}) <= 253)
62 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);
63 if (ord($c{0}) >= 254 && ord($c{0}) <= 255)
77 if ((!is_numeric($character)) || ($character < 0)) {
81 if (function_exists(
'mb_convert_encoding')) {
82 return mb_convert_encoding(
'&#'.intval($character).
';',
'UTF-8',
'HTML-ENTITIES');
84 return chr(intval($character));
98 if (is_bool($stringValue)) {
102 if (self::$_invalidChars == Null) {
103 self::$_invalidChars =
range(chr(0),chr(31));
106 if (is_string($stringValue) || is_numeric($stringValue)) {
107 return str_replace(self::$_invalidChars,
'', trim($stringValue,
"\x00..\x1F"));
121 if (is_bool($stringValue)) {
125 if (is_string($stringValue) || is_numeric($stringValue)) {
126 return trim(preg_replace(
'/ +/',
' ',trim($stringValue,
' ')),
' ');
139 if (($characters === NULL) || ($characters ===
''))
142 if (is_bool($characters)) {
144 $characters = (int) $characters;
150 $character = $characters;
151 if ((function_exists(
'mb_strlen')) && (function_exists(
'mb_substr'))) {
152 if (mb_strlen($characters,
'UTF-8') > 1) { $character = mb_substr($characters, 0, 1,
'UTF-8'); }
153 return self::_uniord($character);
155 if (strlen($characters) > 0) { $character = substr($characters, 0, 1); }
156 return ord($character);
172 foreach ($aArgs as $arg) {
180 $returnValue .= $arg;
200 public static function DOLLAR($value = 0, $decimals = 2) {
205 if (!is_numeric($value) || !is_numeric($decimals)) {
208 $decimals = floor($decimals);
212 $mask .=
'.' . str_repeat(
'0',$decimals);
214 $round = pow(10,abs($decimals));
215 if ($value < 0) { $round = 0-$round; }
237 if (!is_bool($needle)) {
238 if (is_bool($haystack)) {
246 if (function_exists(
'mb_strpos')) {
247 $pos = mb_strpos($haystack, $needle, --$offset,
'UTF-8');
249 $pos = strpos($haystack, $needle, --$offset);
251 if ($pos !==
false) {
273 if (!is_bool($needle)) {
274 if (is_bool($haystack)) {
282 if (function_exists(
'mb_stripos')) {
283 $pos = mb_stripos($haystack, $needle, --$offset,
'UTF-8');
285 $pos = stripos($haystack, $needle, --$offset);
287 if ($pos !==
false) {
304 public static function FIXEDFORMAT($value, $decimals = 2, $no_commas = FALSE) {
310 if (!is_numeric($value) || !is_numeric($decimals)) {
313 $decimals = floor($decimals);
315 $valueResult = round($value,$decimals);
316 if ($decimals < 0) { $decimals = 0; }
318 $valueResult = number_format($valueResult,$decimals);
321 return (
string) $valueResult;
332 public static function LEFT($value =
'', $chars = 1) {
340 if (is_bool($value)) {
344 if (function_exists(
'mb_substr')) {
345 return mb_substr($value, 0, $chars,
'UTF-8');
347 return substr($value, 0, $chars);
360 public static function MID($value =
'',
$start = 1, $chars = null) {
365 if ((
$start < 1) || ($chars < 0)) {
369 if (is_bool($value)) {
373 if (function_exists(
'mb_substr')) {
374 return mb_substr($value, --
$start, $chars,
'UTF-8');
376 return substr($value, --
$start, $chars);
388 public static function RIGHT($value =
'', $chars = 1) {
396 if (is_bool($value)) {
400 if ((function_exists(
'mb_substr')) && (function_exists(
'mb_strlen'))) {
401 return mb_substr($value, mb_strlen($value,
'UTF-8') - $chars, $chars,
'UTF-8');
403 return substr($value, strlen($value) - $chars);
417 if (is_bool($value)) {
421 if (function_exists(
'mb_strlen')) {
422 return mb_strlen($value,
'UTF-8');
424 return strlen($value);
440 if (is_bool($mixedCaseString)) {
459 if (is_bool($mixedCaseString)) {
478 if (is_bool($mixedCaseString)) {
495 public static function REPLACE($oldText =
'',
$start = 1, $chars = null, $newText) {
501 $left = self::LEFT($oldText,
$start-1);
502 $right = self::RIGHT($oldText,self::STRINGLENGTH($oldText)-(
$start+$chars)+1);
504 return $left.$newText.$right;
517 public static function SUBSTITUTE(
$text =
'', $fromText =
'', $toText =
'', $instance = 0) {
523 if ($instance == 0) {
524 if(function_exists(
'mb_str_replace')) {
525 return mb_str_replace($fromText,$toText,
$text);
527 return str_replace($fromText,$toText,
$text);
531 while($instance > 0) {
532 if (function_exists(
'mb_strpos')) {
533 $pos = mb_strpos(
$text, $fromText, $pos+1,
'UTF-8');
535 $pos = strpos(
$text, $fromText, $pos+1);
537 if ($pos ===
false) {
542 if ($pos !==
false) {
543 if (function_exists(
'mb_strlen')) {
544 return self::REPLACE(
$text,++$pos,mb_strlen($fromText,
'UTF-8'),$toText);
546 return self::REPLACE(
$text,++$pos,strlen($fromText),$toText);
564 if (is_string($testValue)) {
595 public static function VALUE($value =
'') {
598 if (!is_numeric($value)) {
599 $numberValue = str_replace(
604 if (is_numeric($numberValue)) {
605 return (
float) $numberValue;
611 if (strpos($value,
':') !==
false) {
627 return (
float) $value;
static getCurrencyCode()
Get the currency code.
static getTRUE()
Return the locale-specific translation of TRUE.
static TRIMNONPRINTABLE($stringValue='')
TRIMNONPRINTABLE.
static DOLLAR($value=0, $decimals=2)
DOLLAR.
static flattenSingleValue($value='')
Convert an array to a single scalar value by extracting the first element.
static VALUE($value='')
VALUE.
static LOWERCASE($mixedCaseString)
LOWERCASE.
static StrToUpper($pValue='')
Convert a UTF-8 encoded string to upper case.
static StrToTitle($pValue='')
Convert a UTF-8 encoded string to title/proper case (uppercase every first character in each word...
static getThousandsSeparator()
Get the thousands separator.
static REPLACE($oldText='', $start=1, $chars=null, $newText)
REPLACE.
static flattenArray($array)
Convert a multi-dimensional array to a simple 1-dimensional array.
static FIXEDFORMAT($value, $decimals=2, $no_commas=FALSE)
FIXEDFORMAT.
static getFALSE()
Return the locale-specific translation of FALSE.
static ASCIICODE($characters)
ASCIICODE.
static MROUND($number, $multiple)
MROUND.
static UPPERCASE($mixedCaseString)
UPPERCASE.
static TEXTFORMAT($value, $format)
TEXTFORMAT.
static SEARCHINSENSITIVE($needle, $haystack, $offset=1)
SEARCHINSENSITIVE.
static DATEVALUE($dateValue=1)
static TIMEVALUE($timeValue)
static LEFT($value='', $chars=1)
LEFT.
static CONCATENATE()
CONCATENATE.
static getReturnDateType()
const COMPATIBILITY_OPENOFFICE
static getCompatibilityMode()
static setReturnDateType($returnDateType)
static isDateTimeFormatCode($pFormatCode='')
Is a given number format code a date/time?
static SEARCHSENSITIVE($needle, $haystack, $offset=1)
SEARCHSENSITIVE.
static SUBSTITUTE($text='', $fromText='', $toText='', $instance=0)
SUBSTITUTE.
static MID($value='', $start=1, $chars=null)
MID.
static RIGHT($value='', $chars=1)
RIGHT.
static CHARACTER($character)
CHARACTER.
static RETURNSTRING($testValue='')
RETURNSTRING.
defined( 'APPLICATION_ENV')||define( 'APPLICATION_ENV'
static STRINGLENGTH($value='')
STRINGLENGTH.
static PROPERCASE($mixedCaseString)
PROPERCASE.
static StrToLower($pValue='')
Convert a UTF-8 encoded string to lower case.
static CountCharacters($value, $enc='UTF-8')
Get character count.
static TRIMSPACES($stringValue='')
TRIMSPACES.