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

Public Member Functions

 updateInCollection ()
 Update the cell into the cell collection. More...
 
 detach ()
 
 attach (Cells $parent)
 
 __construct ($pValue, $pDataType, Worksheet $pSheet)
 Create a new Cell. More...
 
 getColumn ()
 Get cell coordinate column. More...
 
 getRow ()
 Get cell coordinate row. More...
 
 getCoordinate ()
 Get cell coordinate. More...
 
 getValue ()
 Get cell value. More...
 
 getFormattedValue ()
 Get cell value with formatting. More...
 
 setValue ($pValue)
 Set cell value. More...
 
 setValueExplicit ($pValue, $pDataType)
 Set the value for a cell, with the explicit data type passed to the method (bypassing any use of the value binder). More...
 
 getCalculatedValue ($resetLog=true)
 Get calculated cell value. More...
 
 setCalculatedValue ($pValue)
 Set old calculated value (cached). More...
 
 getOldCalculatedValue ()
 Get old calculated value (cached) This returns the value last calculated by MS Excel or whichever spreadsheet program was used to create the original spreadsheet file. More...
 
 getDataType ()
 Get cell data type. More...
 
 setDataType ($pDataType)
 Set cell data type. More...
 
 isFormula ()
 Identify if the cell contains a formula. More...
 
 hasDataValidation ()
 Does this cell contain Data validation rules? More...
 
 getDataValidation ()
 Get Data validation rules. More...
 
 setDataValidation (?DataValidation $pDataValidation=null)
 Set Data validation rules. More...
 
 hasValidValue ()
 Does this cell contain valid value? More...
 
 hasHyperlink ()
 Does this cell contain a Hyperlink? More...
 
 getHyperlink ()
 Get Hyperlink. More...
 
 setHyperlink (?Hyperlink $pHyperlink=null)
 Set Hyperlink. More...
 
 getParent ()
 Get cell collection. More...
 
 getWorksheet ()
 Get parent worksheet. More...
 
 isInMergeRange ()
 Is this cell in a merge range. More...
 
 isMergeRangeValueCell ()
 Is this cell the master (top left cell) in a merge range (that holds the actual data value). More...
 
 getMergeRange ()
 If this cell is in a merge range, then return the range. More...
 
 getStyle ()
 Get cell style. More...
 
 rebindParent (Worksheet $parent)
 Re-bind parent. More...
 
 isInRange ($pRange)
 Is cell in a specific range? More...
 
 __clone ()
 Implement PHP __clone to create a deep clone, not just a shallow copy. More...
 
 getXfIndex ()
 Get index to cellXf. More...
 
 setXfIndex ($pValue)
 Set index to cellXf. More...
 
 setFormulaAttributes ($pAttributes)
 Set the formula attributes. More...
 
 getFormulaAttributes ()
 Get the formula attributes. More...
 
 __toString ()
 Convert to string. More...
 

Static Public Member Functions

static compareCells (self $a, self $b)
 Compare 2 cells. More...
 
static getValueBinder ()
 Get value binder to use. More...
 
static setValueBinder (IValueBinder $binder)
 Set value binder to use. More...
 

Private Attributes

 $value
 
 $calculatedValue
 
 $dataType
 
 $parent
 
 $xfIndex = 0
 
 $formulaAttributes
 Attributes of the formula. More...
 

Static Private Attributes

static $valueBinder
 

Detailed Description

Definition at line 13 of file Cell.php.

Constructor & Destructor Documentation

◆ __construct()

PhpOffice\PhpSpreadsheet\Cell\Cell::__construct (   $pValue,
  $pDataType,
Worksheet  $pSheet 
)

Create a new Cell.

Parameters
mixed$pValue
string$pDataType

Definition at line 96 of file Cell.php.

97 {
98 // Initialise cell value
99 $this->value = $pValue;
100
101 // Set worksheet cache
102 $this->parent = $pSheet->getCellCollection();
103
104 // Set datatype?
105 if ($pDataType !== null) {
106 if ($pDataType == DataType::TYPE_STRING2) {
107 $pDataType = DataType::TYPE_STRING;
108 }
109 $this->dataType = $pDataType;
110 } elseif (!self::getValueBinder()->bindValue($this, $pValue)) {
111 throw new Exception('Value could not be bound to cell.');
112 }
113 }

References PhpOffice\PhpSpreadsheet\Cell\DataType\TYPE_STRING, and PhpOffice\PhpSpreadsheet\Cell\DataType\TYPE_STRING2.

Member Function Documentation

◆ __clone()

PhpOffice\PhpSpreadsheet\Cell\Cell::__clone ( )

Implement PHP __clone to create a deep clone, not just a shallow copy.

Definition at line 616 of file Cell.php.

617 {
618 $vars = get_object_vars($this);
619 foreach ($vars as $key => $value) {
620 if ((is_object($value)) && ($key != 'parent')) {
621 $this->$key = clone $value;
622 } else {
623 $this->$key = $value;
624 }
625 }
626 }
$key
Definition: croninfo.php:18

References $key, and PhpOffice\PhpSpreadsheet\Cell\Cell\$value.

◆ __toString()

PhpOffice\PhpSpreadsheet\Cell\Cell::__toString ( )

Convert to string.

Returns
string

Definition at line 679 of file Cell.php.

680 {
681 return (string) $this->getValue();
682 }
getValue()
Get cell value.
Definition: Cell.php:150

References PhpOffice\PhpSpreadsheet\Cell\Cell\getValue().

+ Here is the call graph for this function:

◆ attach()

PhpOffice\PhpSpreadsheet\Cell\Cell::attach ( Cells  $parent)

Definition at line 85 of file Cell.php.

85 : void
86 {
87 $this->parent = $parent;
88 }

References PhpOffice\PhpSpreadsheet\Cell\Cell\$parent.

◆ compareCells()

static PhpOffice\PhpSpreadsheet\Cell\Cell::compareCells ( self  $a,
self  $b 
)
static

Compare 2 cells.

Parameters
Cell$aCell a
Cell$bCell b
Returns
int Result of comparison (always -1 or 1, never zero!)

Definition at line 578 of file Cell.php.

579 {
580 if ($a->getRow() < $b->getRow()) {
581 return -1;
582 } elseif ($a->getRow() > $b->getRow()) {
583 return 1;
584 } elseif (Coordinate::columnIndexFromString($a->getColumn()) < Coordinate::columnIndexFromString($b->getColumn())) {
585 return -1;
586 }
587
588 return 1;
589 }
static columnIndexFromString($pString)
Column index from string.
Definition: Coordinate.php:265

References PhpOffice\PhpSpreadsheet\Cell\Coordinate\columnIndexFromString().

+ Here is the call graph for this function:

◆ detach()

PhpOffice\PhpSpreadsheet\Cell\Cell::detach ( )

Definition at line 79 of file Cell.php.

79 : void
80 {
81 // @phpstan-ignore-next-line
82 $this->parent = null;
83 }

◆ getCalculatedValue()

PhpOffice\PhpSpreadsheet\Cell\Cell::getCalculatedValue (   $resetLog = true)

Get calculated cell value.

Parameters
bool$resetLogWhether the calculation engine logger should be reset or not
Returns
mixed

Definition at line 251 of file Cell.php.

252 {
253 if ($this->dataType == DataType::TYPE_FORMULA) {
254 try {
255 $index = $this->getWorksheet()->getParent()->getActiveSheetIndex();
256 $selected = $this->getWorksheet()->getSelectedCells();
258 $this->getWorksheet()->getParent()
259 )->calculateCellValue($this, $resetLog);
260 $this->getWorksheet()->setSelectedCells($selected);
261 $this->getWorksheet()->getParent()->setActiveSheetIndex($index);
262 // We don't yet handle array returns
263 if (is_array($result)) {
264 while (is_array($result)) {
265 $result = array_shift($result);
266 }
267 }
268 } catch (Exception $ex) {
269 if (($ex->getMessage() === 'Unable to access External Workbook') && ($this->calculatedValue !== null)) {
270 return $this->calculatedValue; // Fallback for calculations referencing external files.
271 } elseif (preg_match('/[Uu]ndefined (name|offset: 2|array key 2)/', $ex->getMessage()) === 1) {
272 return \PhpOffice\PhpSpreadsheet\Calculation\Functions::NAME();
273 }
274
275 throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(
276 $this->getWorksheet()->getTitle() . '!' . $this->getCoordinate() . ' -> ' . $ex->getMessage()
277 );
278 }
279
280 if ($result === '#Not Yet Implemented') {
281 return $this->calculatedValue; // Fallback if calculation engine does not support the formula.
282 }
283
284 return $result;
285 } elseif ($this->value instanceof RichText) {
286 return $this->value->getPlainText();
287 }
288
289 return $this->value;
290 }
$result
static getInstance(?Spreadsheet $spreadsheet=null)
Get an instance of this class.
getWorksheet()
Get parent worksheet.
Definition: Cell.php:479
getParent()
Get cell collection.
Definition: Cell.php:469
getCoordinate()
Get cell coordinate.
Definition: Cell.php:140
$index
Definition: metadata.php:60

References PhpOffice\PhpSpreadsheet\Cell\Cell\$calculatedValue, $index, $result, PhpOffice\PhpSpreadsheet\Cell\Cell\$value, PhpOffice\PhpSpreadsheet\Cell\Cell\getCoordinate(), PhpOffice\PhpSpreadsheet\Calculation\Calculation\getInstance(), PhpOffice\PhpSpreadsheet\Cell\Cell\getParent(), PhpOffice\PhpSpreadsheet\Cell\Cell\getWorksheet(), and PhpOffice\PhpSpreadsheet\Cell\DataType\TYPE_FORMULA.

Referenced by PhpOffice\PhpSpreadsheet\Cell\Cell\getFormattedValue(), PhpOffice\PhpSpreadsheet\Shared\Date\isDateTime(), and PhpOffice\PhpSpreadsheet\Writer\Xlsx\Worksheet\writeCellFormula().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getColumn()

PhpOffice\PhpSpreadsheet\Cell\Cell::getColumn ( )

Get cell coordinate column.

Returns
string

Definition at line 120 of file Cell.php.

121 {
122 return $this->parent->getCurrentColumn();
123 }

Referenced by PhpOffice\PhpSpreadsheet\Calculation\LookupRef\RowColumnInformation\cellColumn(), PhpOffice\PhpSpreadsheet\Calculation\Calculation\evaluateDefinedName(), and PhpOffice\PhpSpreadsheet\Cell\Cell\isInRange().

+ Here is the caller graph for this function:

◆ getCoordinate()

◆ getDataType()

PhpOffice\PhpSpreadsheet\Cell\Cell::getDataType ( )

Get cell data type.

Returns
string

Definition at line 328 of file Cell.php.

329 {
330 return $this->dataType;
331 }

References PhpOffice\PhpSpreadsheet\Cell\Cell\$dataType.

◆ getDataValidation()

PhpOffice\PhpSpreadsheet\Cell\Cell::getDataValidation ( )

Get Data validation rules.

Returns
DataValidation

Definition at line 379 of file Cell.php.

380 {
381 if (!isset($this->parent)) {
382 throw new Exception('Cannot get data validation for cell that is not bound to a worksheet');
383 }
384
385 return $this->getWorksheet()->getDataValidation($this->getCoordinate());
386 }

References PhpOffice\PhpSpreadsheet\Cell\Cell\getCoordinate(), and PhpOffice\PhpSpreadsheet\Cell\Cell\getWorksheet().

Referenced by PhpOffice\PhpSpreadsheet\Cell\DataValidator\isValid(), and PhpOffice\PhpSpreadsheet\Cell\DataValidator\isValueInList().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFormattedValue()

PhpOffice\PhpSpreadsheet\Cell\Cell::getFormattedValue ( )

Get cell value with formatting.

Returns
string

Definition at line 160 of file Cell.php.

161 {
162 return (string) NumberFormat::toFormattedString(
163 $this->getCalculatedValue(),
164 $this->getStyle()
165 ->getNumberFormat()->getFormatCode()
166 );
167 }
getStyle()
Get cell style.
Definition: Cell.php:533
getCalculatedValue($resetLog=true)
Get calculated cell value.
Definition: Cell.php:251
static toFormattedString($value, $format, $callBack=null)
Convert a value in a pre-defined format to a PHP string.

References PhpOffice\PhpSpreadsheet\Cell\Cell\getCalculatedValue(), PhpOffice\PhpSpreadsheet\Cell\Cell\getStyle(), and PhpOffice\PhpSpreadsheet\Style\NumberFormat\toFormattedString().

+ Here is the call graph for this function:

◆ getFormulaAttributes()

PhpOffice\PhpSpreadsheet\Cell\Cell::getFormulaAttributes ( )

Get the formula attributes.

Definition at line 669 of file Cell.php.

670 {
672 }
$formulaAttributes
Attributes of the formula.
Definition: Cell.php:65

References PhpOffice\PhpSpreadsheet\Cell\Cell\$formulaAttributes.

◆ getHyperlink()

PhpOffice\PhpSpreadsheet\Cell\Cell::getHyperlink ( )

Get Hyperlink.

Returns
Hyperlink

Definition at line 437 of file Cell.php.

438 {
439 if (!isset($this->parent)) {
440 throw new Exception('Cannot get hyperlink for cell that is not bound to a worksheet');
441 }
442
443 return $this->getWorksheet()->getHyperlink($this->getCoordinate());
444 }

References PhpOffice\PhpSpreadsheet\Cell\Cell\getCoordinate(), and PhpOffice\PhpSpreadsheet\Cell\Cell\getWorksheet().

Referenced by PhpOffice\PhpSpreadsheet\Calculation\LookupRef\Hyperlink\set().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getMergeRange()

PhpOffice\PhpSpreadsheet\Cell\Cell::getMergeRange ( )

If this cell is in a merge range, then return the range.

Returns
false|string

Definition at line 517 of file Cell.php.

518 {
519 foreach ($this->getWorksheet()->getMergeCells() as $mergeRange) {
520 if ($this->isInRange($mergeRange)) {
521 return $mergeRange;
522 }
523 }
524
525 return false;
526 }
isInRange($pRange)
Is cell in a specific range?
Definition: Cell.php:557

References PhpOffice\PhpSpreadsheet\Cell\Cell\getWorksheet(), and PhpOffice\PhpSpreadsheet\Cell\Cell\isInRange().

Referenced by PhpOffice\PhpSpreadsheet\Cell\Cell\isInMergeRange(), PhpOffice\PhpSpreadsheet\Cell\Cell\isMergeRangeValueCell(), and PhpOffice\PhpSpreadsheet\Writer\Ods\Content\writeCellMerge().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getOldCalculatedValue()

PhpOffice\PhpSpreadsheet\Cell\Cell::getOldCalculatedValue ( )

Get old calculated value (cached) This returns the value last calculated by MS Excel or whichever spreadsheet program was used to create the original spreadsheet file.

Note that this value is not guaranteed to reflect the actual calculated value because it is possible that auto-calculation was disabled in the original spreadsheet, and underlying data values used by the formula have changed since it was last calculated.

Returns
mixed

Definition at line 318 of file Cell.php.

319 {
321 }

References PhpOffice\PhpSpreadsheet\Cell\Cell\$calculatedValue.

◆ getParent()

PhpOffice\PhpSpreadsheet\Cell\Cell::getParent ( )

Get cell collection.

Returns
Cells

Definition at line 469 of file Cell.php.

470 {
471 return $this->parent;
472 }

References PhpOffice\PhpSpreadsheet\Cell\Cell\$parent.

Referenced by PhpOffice\PhpSpreadsheet\Cell\Cell\getCalculatedValue().

+ Here is the caller graph for this function:

◆ getRow()

PhpOffice\PhpSpreadsheet\Cell\Cell::getRow ( )

Get cell coordinate row.

Returns
int

Definition at line 130 of file Cell.php.

131 {
132 return $this->parent->getCurrentRow();
133 }

Referenced by PhpOffice\PhpSpreadsheet\Calculation\LookupRef\RowColumnInformation\cellRow(), PhpOffice\PhpSpreadsheet\Calculation\Calculation\evaluateDefinedName(), and PhpOffice\PhpSpreadsheet\Cell\Cell\isInRange().

+ Here is the caller graph for this function:

◆ getStyle()

PhpOffice\PhpSpreadsheet\Cell\Cell::getStyle ( )

Get cell style.

Returns
Style

Definition at line 533 of file Cell.php.

534 {
535 return $this->getWorksheet()->getStyle($this->getCoordinate());
536 }

References PhpOffice\PhpSpreadsheet\Cell\Cell\getCoordinate(), and PhpOffice\PhpSpreadsheet\Cell\Cell\getWorksheet().

Referenced by PhpOffice\PhpSpreadsheet\Cell\Cell\getFormattedValue(), and ilExcel\setDateFormat().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getValue()

PhpOffice\PhpSpreadsheet\Cell\Cell::getValue ( )

Get cell value.

Returns
mixed

Definition at line 150 of file Cell.php.

151 {
152 return $this->value;
153 }

References PhpOffice\PhpSpreadsheet\Cell\Cell\$value.

Referenced by PhpOffice\PhpSpreadsheet\Cell\Cell\__toString(), PhpOffice\PhpSpreadsheet\Cell\DataValidator\isValid(), and PhpOffice\PhpSpreadsheet\Cell\DataValidator\isValueInList().

+ Here is the caller graph for this function:

◆ getValueBinder()

static PhpOffice\PhpSpreadsheet\Cell\Cell::getValueBinder ( )
static

Get value binder to use.

Returns
IValueBinder

Definition at line 596 of file Cell.php.

597 {
598 if (self::$valueBinder === null) {
599 self::$valueBinder = new DefaultValueBinder();
600 }
601
602 return self::$valueBinder;
603 }

References PhpOffice\PhpSpreadsheet\Cell\Cell\$valueBinder.

◆ getWorksheet()

◆ getXfIndex()

PhpOffice\PhpSpreadsheet\Cell\Cell::getXfIndex ( )

Get index to cellXf.

Returns
int

Definition at line 633 of file Cell.php.

634 {
635 return $this->xfIndex;
636 }

References PhpOffice\PhpSpreadsheet\Cell\Cell\$xfIndex.

◆ hasDataValidation()

PhpOffice\PhpSpreadsheet\Cell\Cell::hasDataValidation ( )

Does this cell contain Data validation rules?

Returns
bool

Definition at line 365 of file Cell.php.

366 {
367 if (!isset($this->parent)) {
368 throw new Exception('Cannot check for data validation when cell is not bound to a worksheet');
369 }
370
371 return $this->getWorksheet()->dataValidationExists($this->getCoordinate());
372 }

References PhpOffice\PhpSpreadsheet\Cell\Cell\getCoordinate(), and PhpOffice\PhpSpreadsheet\Cell\Cell\getWorksheet().

Referenced by PhpOffice\PhpSpreadsheet\Cell\DataValidator\isValid().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasHyperlink()

PhpOffice\PhpSpreadsheet\Cell\Cell::hasHyperlink ( )

Does this cell contain a Hyperlink?

Returns
bool

Definition at line 423 of file Cell.php.

424 {
425 if (!isset($this->parent)) {
426 throw new Exception('Cannot check for hyperlink when cell is not bound to a worksheet');
427 }
428
429 return $this->getWorksheet()->hyperlinkExists($this->getCoordinate());
430 }

References PhpOffice\PhpSpreadsheet\Cell\Cell\getCoordinate(), and PhpOffice\PhpSpreadsheet\Cell\Cell\getWorksheet().

+ Here is the call graph for this function:

◆ hasValidValue()

PhpOffice\PhpSpreadsheet\Cell\Cell::hasValidValue ( )

Does this cell contain valid value?

Returns
bool

Definition at line 411 of file Cell.php.

412 {
413 $validator = new DataValidator();
414
415 return $validator->isValid($this);
416 }

◆ isFormula()

PhpOffice\PhpSpreadsheet\Cell\Cell::isFormula ( )

Identify if the cell contains a formula.

Returns
bool

Definition at line 355 of file Cell.php.

356 {
357 return $this->dataType == DataType::TYPE_FORMULA;
358 }

References PhpOffice\PhpSpreadsheet\Cell\DataType\TYPE_FORMULA.

◆ isInMergeRange()

PhpOffice\PhpSpreadsheet\Cell\Cell::isInMergeRange ( )

Is this cell in a merge range.

Returns
bool

Definition at line 489 of file Cell.php.

490 {
491 return (bool) $this->getMergeRange();
492 }
getMergeRange()
If this cell is in a merge range, then return the range.
Definition: Cell.php:517

References PhpOffice\PhpSpreadsheet\Cell\Cell\getMergeRange().

+ Here is the call graph for this function:

◆ isInRange()

PhpOffice\PhpSpreadsheet\Cell\Cell::isInRange (   $pRange)

Is cell in a specific range?

Parameters
string$pRangeCell range (e.g. A1:A1)
Returns
bool

Definition at line 557 of file Cell.php.

558 {
559 [$rangeStart, $rangeEnd] = Coordinate::rangeBoundaries($pRange);
560
561 // Translate properties
562 $myColumn = Coordinate::columnIndexFromString($this->getColumn());
563 $myRow = $this->getRow();
564
565 // Verify if cell is in range
566 return ($rangeStart[0] <= $myColumn) && ($rangeEnd[0] >= $myColumn) &&
567 ($rangeStart[1] <= $myRow) && ($rangeEnd[1] >= $myRow);
568 }
getColumn()
Get cell coordinate column.
Definition: Cell.php:120
getRow()
Get cell coordinate row.
Definition: Cell.php:130
static rangeBoundaries($pRange)
Calculate range boundaries.
Definition: Coordinate.php:187

References PhpOffice\PhpSpreadsheet\Cell\Coordinate\columnIndexFromString(), PhpOffice\PhpSpreadsheet\Cell\Cell\getColumn(), PhpOffice\PhpSpreadsheet\Cell\Cell\getRow(), and PhpOffice\PhpSpreadsheet\Cell\Coordinate\rangeBoundaries().

Referenced by PhpOffice\PhpSpreadsheet\Cell\Cell\getMergeRange().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isMergeRangeValueCell()

PhpOffice\PhpSpreadsheet\Cell\Cell::isMergeRangeValueCell ( )

Is this cell the master (top left cell) in a merge range (that holds the actual data value).

Returns
bool

Definition at line 499 of file Cell.php.

500 {
501 if ($mergeRange = $this->getMergeRange()) {
502 $mergeRange = Coordinate::splitRange($mergeRange);
503 [$startCell] = $mergeRange[0];
504 if ($this->getCoordinate() === $startCell) {
505 return true;
506 }
507 }
508
509 return false;
510 }
static splitRange($pRange)
Split range into coordinate strings.
Definition: Coordinate.php:140

References PhpOffice\PhpSpreadsheet\Cell\Cell\getCoordinate(), PhpOffice\PhpSpreadsheet\Cell\Cell\getMergeRange(), and PhpOffice\PhpSpreadsheet\Cell\Coordinate\splitRange().

Referenced by PhpOffice\PhpSpreadsheet\Writer\Ods\Content\writeCellMerge().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ rebindParent()

PhpOffice\PhpSpreadsheet\Cell\Cell::rebindParent ( Worksheet  $parent)

Re-bind parent.

Returns
Cell

Definition at line 543 of file Cell.php.

544 {
545 $this->parent = $parent->getCellCollection();
546
547 return $this->updateInCollection();
548 }
updateInCollection()
Update the cell into the cell collection.
Definition: Cell.php:72

References PhpOffice\PhpSpreadsheet\Cell\Cell\$parent, and PhpOffice\PhpSpreadsheet\Cell\Cell\updateInCollection().

+ Here is the call graph for this function:

◆ setCalculatedValue()

PhpOffice\PhpSpreadsheet\Cell\Cell::setCalculatedValue (   $pValue)

Set old calculated value (cached).

Parameters
mixed$pValueValue
Returns
Cell

Definition at line 299 of file Cell.php.

300 {
301 if ($pValue !== null) {
302 $this->calculatedValue = (is_numeric($pValue)) ? (float) $pValue : $pValue;
303 }
304
305 return $this->updateInCollection();
306 }

References PhpOffice\PhpSpreadsheet\Cell\Cell\updateInCollection().

+ Here is the call graph for this function:

◆ setDataType()

PhpOffice\PhpSpreadsheet\Cell\Cell::setDataType (   $pDataType)

Set cell data type.

Parameters
string$pDataTypesee DataType::TYPE_*
Returns
Cell

Definition at line 340 of file Cell.php.

341 {
342 if ($pDataType == DataType::TYPE_STRING2) {
343 $pDataType = DataType::TYPE_STRING;
344 }
345 $this->dataType = $pDataType;
346
347 return $this->updateInCollection();
348 }

References PhpOffice\PhpSpreadsheet\Cell\DataType\TYPE_STRING, PhpOffice\PhpSpreadsheet\Cell\DataType\TYPE_STRING2, and PhpOffice\PhpSpreadsheet\Cell\Cell\updateInCollection().

+ Here is the call graph for this function:

◆ setDataValidation()

PhpOffice\PhpSpreadsheet\Cell\Cell::setDataValidation ( ?DataValidation  $pDataValidation = null)

Set Data validation rules.

Parameters
DataValidation$pDataValidation
Returns
Cell

Definition at line 395 of file Cell.php.

396 {
397 if (!isset($this->parent)) {
398 throw new Exception('Cannot set data validation for cell that is not bound to a worksheet');
399 }
400
401 $this->getWorksheet()->setDataValidation($this->getCoordinate(), $pDataValidation);
402
403 return $this->updateInCollection();
404 }

References PhpOffice\PhpSpreadsheet\Cell\Cell\getCoordinate(), PhpOffice\PhpSpreadsheet\Cell\Cell\getWorksheet(), and PhpOffice\PhpSpreadsheet\Cell\Cell\updateInCollection().

+ Here is the call graph for this function:

◆ setFormulaAttributes()

PhpOffice\PhpSpreadsheet\Cell\Cell::setFormulaAttributes (   $pAttributes)

Set the formula attributes.

Parameters
mixed$pAttributes
Returns
$this

Definition at line 659 of file Cell.php.

660 {
661 $this->formulaAttributes = $pAttributes;
662
663 return $this;
664 }

◆ setHyperlink()

PhpOffice\PhpSpreadsheet\Cell\Cell::setHyperlink ( ?Hyperlink  $pHyperlink = null)

Set Hyperlink.

Parameters
Hyperlink$pHyperlink
Returns
Cell

Definition at line 453 of file Cell.php.

454 {
455 if (!isset($this->parent)) {
456 throw new Exception('Cannot set hyperlink for cell that is not bound to a worksheet');
457 }
458
459 $this->getWorksheet()->setHyperlink($this->getCoordinate(), $pHyperlink);
460
461 return $this->updateInCollection();
462 }

References PhpOffice\PhpSpreadsheet\Cell\Cell\getCoordinate(), PhpOffice\PhpSpreadsheet\Cell\Cell\getWorksheet(), and PhpOffice\PhpSpreadsheet\Cell\Cell\updateInCollection().

+ Here is the call graph for this function:

◆ setValue()

PhpOffice\PhpSpreadsheet\Cell\Cell::setValue (   $pValue)

Set cell value.

Sets the value for a cell, automatically determining the datatype using the value binder

Parameters
mixed$pValueValue
Returns
$this

Definition at line 178 of file Cell.php.

179 {
180 if (!self::getValueBinder()->bindValue($this, $pValue)) {
181 throw new Exception('Value could not be bound to cell.');
182 }
183
184 return $this;
185 }

◆ setValueBinder()

static PhpOffice\PhpSpreadsheet\Cell\Cell::setValueBinder ( IValueBinder  $binder)
static

Set value binder to use.

Definition at line 608 of file Cell.php.

608 : void
609 {
610 self::$valueBinder = $binder;
611 }

◆ setValueExplicit()

PhpOffice\PhpSpreadsheet\Cell\Cell::setValueExplicit (   $pValue,
  $pDataType 
)

Set the value for a cell, with the explicit data type passed to the method (bypassing any use of the value binder).

Parameters
mixed$pValueValue
string$pDataTypeExplicit data type, see DataType::TYPE_*
Returns
Cell

Definition at line 195 of file Cell.php.

196 {
197 // set the value according to data type
198 switch ($pDataType) {
200 $this->value = $pValue;
201
202 break;
204 $pDataType = DataType::TYPE_STRING;
205 // no break
207 // Synonym for string
209 // Rich text
210 $this->value = DataType::checkString($pValue);
211
212 break;
214 if (is_string($pValue) && !is_numeric($pValue)) {
215 throw new Exception('Invalid numeric value for datatype Numeric');
216 }
217 $this->value = 0 + $pValue;
218
219 break;
221 $this->value = (string) $pValue;
222
223 break;
225 $this->value = (bool) $pValue;
226
227 break;
229 $this->value = DataType::checkErrorCode($pValue);
230
231 break;
232 default:
233 throw new Exception('Invalid datatype: ' . $pDataType);
234
235 break;
236 }
237
238 // set the datatype
239 $this->dataType = $pDataType;
240
241 return $this->updateInCollection();
242 }
static checkErrorCode($pValue)
Check a value that it is a valid error code.
Definition: DataType.php:75
static checkString($pValue)
Check a string that it satisfies Excel requirements.
Definition: DataType.php:52

References PhpOffice\PhpSpreadsheet\Cell\DataType\checkErrorCode(), PhpOffice\PhpSpreadsheet\Cell\DataType\checkString(), 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, PhpOffice\PhpSpreadsheet\Cell\DataType\TYPE_STRING, PhpOffice\PhpSpreadsheet\Cell\DataType\TYPE_STRING2, and PhpOffice\PhpSpreadsheet\Cell\Cell\updateInCollection().

Referenced by PhpOffice\PhpSpreadsheet\Cell\DefaultValueBinder\bindValue(), PhpOffice\PhpSpreadsheet\Cell\StringValueBinder\bindValue(), PhpOffice\PhpSpreadsheet\Cell\AdvancedValueBinder\bindValue(), PhpOffice\PhpSpreadsheet\Cell\AdvancedValueBinder\setImproperFraction(), PhpOffice\PhpSpreadsheet\Cell\AdvancedValueBinder\setPercentage(), PhpOffice\PhpSpreadsheet\Cell\AdvancedValueBinder\setProperFraction(), PhpOffice\PhpSpreadsheet\Cell\AdvancedValueBinder\setTimeHoursMinutes(), and PhpOffice\PhpSpreadsheet\Cell\AdvancedValueBinder\setTimeHoursMinutesSeconds().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setXfIndex()

PhpOffice\PhpSpreadsheet\Cell\Cell::setXfIndex (   $pValue)

Set index to cellXf.

Parameters
int$pValue
Returns
Cell

Definition at line 645 of file Cell.php.

646 {
647 $this->xfIndex = $pValue;
648
649 return $this->updateInCollection();
650 }

References PhpOffice\PhpSpreadsheet\Cell\Cell\updateInCollection().

+ Here is the call graph for this function:

◆ updateInCollection()

PhpOffice\PhpSpreadsheet\Cell\Cell::updateInCollection ( )

Field Documentation

◆ $calculatedValue

PhpOffice\PhpSpreadsheet\Cell\Cell::$calculatedValue
private

◆ $dataType

PhpOffice\PhpSpreadsheet\Cell\Cell::$dataType
private

Definition at line 46 of file Cell.php.

Referenced by PhpOffice\PhpSpreadsheet\Cell\Cell\getDataType().

◆ $formulaAttributes

PhpOffice\PhpSpreadsheet\Cell\Cell::$formulaAttributes
private

Attributes of the formula.

Definition at line 65 of file Cell.php.

Referenced by PhpOffice\PhpSpreadsheet\Cell\Cell\getFormulaAttributes().

◆ $parent

PhpOffice\PhpSpreadsheet\Cell\Cell::$parent
private

◆ $value

PhpOffice\PhpSpreadsheet\Cell\Cell::$value
private

◆ $valueBinder

PhpOffice\PhpSpreadsheet\Cell\Cell::$valueBinder
staticprivate

Definition at line 20 of file Cell.php.

Referenced by PhpOffice\PhpSpreadsheet\Cell\Cell\getValueBinder().

◆ $xfIndex

PhpOffice\PhpSpreadsheet\Cell\Cell::$xfIndex = 0
private

Definition at line 60 of file Cell.php.

Referenced by PhpOffice\PhpSpreadsheet\Cell\Cell\getXfIndex().


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