ILIAS
eassessment Revision 61809
◀ ilDoc Overview
Main Page
Related Pages
Modules
Namespaces
Data Structures
Files
Examples
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Groups
Pages
DefaultValueBinder.php
Go to the documentation of this file.
1
<?php
30
if
(!defined(
'PHPEXCEL_ROOT'
)) {
34
define(
'PHPEXCEL_ROOT'
, dirname(__FILE__) .
'/../../'
);
35
require(PHPEXCEL_ROOT .
'PHPExcel/Autoloader.php'
);
36
}
37
38
46
class
PHPExcel_Cell_DefaultValueBinder
implements
PHPExcel_Cell_IValueBinder
47
{
55
public
function
bindValue
(
PHPExcel_Cell
$cell, $value = null)
56
{
57
// sanitize UTF-8 strings
58
if
(is_string($value)) {
59
$value =
PHPExcel_Shared_String::SanitizeUTF8
($value);
60
}
61
62
// Set value explicit
63
$cell->
setValueExplicit
( $value,
PHPExcel_Cell_DataType::dataTypeForValue
($value) );
64
65
// Done!
66
return
true
;
67
}
68
75
public
static
function
dataTypeForValue
($pValue = null) {
76
// Match the value against a few data types
77
if
(is_null($pValue)) {
78
return
PHPExcel_Cell_DataType::TYPE_NULL
;
79
80
} elseif ($pValue ===
''
) {
81
return
PHPExcel_Cell_DataType::TYPE_STRING
;
82
83
} elseif ($pValue instanceof
PHPExcel_RichText
) {
84
return
PHPExcel_Cell_DataType::TYPE_STRING
;
85
86
} elseif ($pValue{0} ===
'='
&& strlen($pValue) > 1) {
87
return
PHPExcel_Cell_DataType::TYPE_FORMULA
;
88
89
} elseif (is_bool($pValue)) {
90
return
PHPExcel_Cell_DataType::TYPE_BOOL
;
91
92
} elseif (is_float($pValue) || is_int($pValue)) {
93
return
PHPExcel_Cell_DataType::TYPE_NUMERIC
;
94
95
} elseif (preg_match(
'/^\-?([0-9]+\\.?[0-9]*|[0-9]*\\.?[0-9]+)$/'
, $pValue)) {
96
return
PHPExcel_Cell_DataType::TYPE_NUMERIC
;
97
98
} elseif (is_string($pValue) && array_key_exists($pValue,
PHPExcel_Cell_DataType::getErrorCodes
())) {
99
return
PHPExcel_Cell_DataType::TYPE_ERROR
;
100
101
}
else
{
102
return
PHPExcel_Cell_DataType::TYPE_STRING
;
103
104
}
105
}
106
}
Services
Excel
PHPExcel
1.7.6
Classes
PHPExcel
Cell
DefaultValueBinder.php
Generated on Mon Apr 25 2016 19:01:26 for ILIAS by
1.8.1.2 (using
Doxyfile
)