ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
PhpOffice\PhpSpreadsheet\Cell\DefaultValueBinder Class Reference
+ Inheritance diagram for PhpOffice\PhpSpreadsheet\Cell\DefaultValueBinder:
+ Collaboration diagram for PhpOffice\PhpSpreadsheet\Cell\DefaultValueBinder:

Public Member Functions

 bindValue (Cell $cell, $value)
 Bind value to a cell. More...
 
 bindValue (Cell $cell, $value)
 Bind value to a cell. More...
 

Static Public Member Functions

static dataTypeForValue ($value)
 DataType for value. More...
 

Detailed Description

Definition at line 9 of file DefaultValueBinder.php.

Member Function Documentation

◆ bindValue()

PhpOffice\PhpSpreadsheet\Cell\DefaultValueBinder::bindValue ( Cell  $cell,
  $value 
)

Bind value to a cell.

Parameters
Cell$cellCell to bind value to
mixed$valueValue to bind in cell
Returns
bool

Implements PhpOffice\PhpSpreadsheet\Cell\IValueBinder.

Reimplemented in PhpOffice\PhpSpreadsheet\Cell\AdvancedValueBinder.

Definition at line 19 of file DefaultValueBinder.php.

20 {
21 // sanitize UTF-8 strings
22 if (is_string($value)) {
23 $value = StringHelper::sanitizeUTF8($value);
24 } elseif (is_object($value)) {
25 // Handle any objects that might be injected
26 if ($value instanceof DateTimeInterface) {
27 $value = $value->format('Y-m-d H:i:s');
28 } elseif (!($value instanceof RichText)) {
29 $value = (string) $value;
30 }
31 }
32
33 // Set value explicit
34 $cell->setValueExplicit($value, static::dataTypeForValue($value));
35
36 // Done!
37 return true;
38 }
static sanitizeUTF8($value)
Try to sanitize UTF8, stripping invalid byte sequences.

References PhpOffice\PhpSpreadsheet\Shared\StringHelper\sanitizeUTF8(), and PhpOffice\PhpSpreadsheet\Cell\Cell\setValueExplicit().

+ Here is the call graph for this function:

◆ dataTypeForValue()

static PhpOffice\PhpSpreadsheet\Cell\DefaultValueBinder::dataTypeForValue (   $value)
static

DataType for value.

Parameters
mixed$value
Returns
string

Definition at line 47 of file DefaultValueBinder.php.

48 {
49 // Match the value against a few data types
50 if ($value === null) {
52 } elseif (is_float($value) || is_int($value)) {
54 } elseif (is_bool($value)) {
56 } elseif ($value === '') {
58 } elseif ($value instanceof RichText) {
60 } elseif (is_string($value) && $value[0] === '=' && strlen($value) > 1) {
62 } elseif (preg_match('/^[\+\-]?(\d+\\.?\d*|\d*\\.?\d+)([Ee][\-\+]?[0-2]?\d{1,3})?$/', $value)) {
63 $tValue = ltrim($value, '+-');
64 if (is_string($value) && $tValue[0] === '0' && strlen($tValue) > 1 && $tValue[1] !== '.') {
66 } elseif ((strpos($value, '.') === false) && ($value > PHP_INT_MAX)) {
68 } elseif (!is_numeric($value)) {
70 }
71
73 } elseif (is_string($value)) {
74 $errorCodes = DataType::getErrorCodes();
75 if (isset($errorCodes[$value])) {
77 }
78 }
79
81 }
static getErrorCodes()
Get list of error codes.
Definition: DataType.php:40

References PhpOffice\PhpSpreadsheet\Cell\DataType\getErrorCodes(), PhpOffice\PhpSpreadsheet\Cell\DataType\TYPE_BOOL, PhpOffice\PhpSpreadsheet\Cell\DataType\TYPE_ERROR, PhpOffice\PhpSpreadsheet\Cell\DataType\TYPE_FORMULA, PhpOffice\PhpSpreadsheet\Cell\DataType\TYPE_INLINE, PhpOffice\PhpSpreadsheet\Cell\DataType\TYPE_NULL, PhpOffice\PhpSpreadsheet\Cell\DataType\TYPE_NUMERIC, and PhpOffice\PhpSpreadsheet\Cell\DataType\TYPE_STRING.

+ Here is the call graph for this function:

The documentation for this class was generated from the following file: