74 $this->
parent->update($this);
99 $this->value = $pValue;
105 if ($pDataType !== null) {
109 $this->dataType = $pDataType;
110 } elseif (!self::getValueBinder()->bindValue($this, $pValue)) {
111 throw new Exception(
'Value could not be bound to cell.');
122 return $this->
parent->getCurrentColumn();
132 return $this->
parent->getCurrentRow();
142 return $this->
parent->getCurrentCoordinate();
165 ->getNumberFormat()->getFormatCode()
180 if (!self::getValueBinder()->bindValue($this, $pValue)) {
181 throw new Exception(
'Value could not be bound to cell.');
198 switch ($pDataType) {
200 $this->value = $pValue;
214 if (is_string($pValue) && !is_numeric($pValue)) {
215 throw new Exception(
'Invalid numeric value for datatype Numeric');
217 $this->value = 0 + $pValue;
221 $this->value = (string) $pValue;
225 $this->value = (bool) $pValue;
233 throw new Exception(
'Invalid datatype: ' . $pDataType);
239 $this->dataType = $pDataType;
259 )->calculateCellValue($this, $resetLog);
269 if (($ex->getMessage() ===
'Unable to access External Workbook') && ($this->calculatedValue !== null)) {
271 } elseif (preg_match(
'/[Uu]ndefined (name|offset: 2|array key 2)/', $ex->getMessage()) === 1) {
272 return \PhpOffice\PhpSpreadsheet\Calculation\Functions::NAME();
275 throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(
280 if (
$result ===
'#Not Yet Implemented') {
285 } elseif ($this->value instanceof
RichText) {
286 return $this->value->getPlainText();
301 if ($pValue !== null) {
302 $this->calculatedValue = (is_numeric($pValue)) ? (
float) $pValue : $pValue;
345 $this->dataType = $pDataType;
367 if (!isset($this->
parent)) {
368 throw new Exception(
'Cannot check for data validation when cell is not bound to a worksheet');
381 if (!isset($this->
parent)) {
382 throw new Exception(
'Cannot get data validation for cell that is not bound to a worksheet');
397 if (!isset($this->
parent)) {
398 throw new Exception(
'Cannot set data validation for cell that is not bound to a worksheet');
415 return $validator->isValid($this);
425 if (!isset($this->
parent)) {
426 throw new Exception(
'Cannot check for hyperlink when cell is not bound to a worksheet');
439 if (!isset($this->
parent)) {
440 throw new Exception(
'Cannot get hyperlink for cell that is not bound to a worksheet');
455 if (!isset($this->
parent)) {
456 throw new Exception(
'Cannot set hyperlink for cell that is not bound to a worksheet');
481 return $this->
parent->getParent();
503 [$startCell] = $mergeRange[0];
519 foreach ($this->
getWorksheet()->getMergeCells() as $mergeRange) {
566 return ($rangeStart[0] <= $myColumn) && ($rangeEnd[0] >= $myColumn) &&
567 ($rangeStart[1] <= $myRow) && ($rangeEnd[1] >= $myRow);
580 if ($a->getRow() < $b->getRow()) {
582 } elseif ($a->getRow() > $b->getRow()) {
598 if (self::$valueBinder === null) {
602 return self::$valueBinder;
610 self::$valueBinder = $binder;
618 $vars = get_object_vars($this);
620 if ((is_object(
$value)) && (
$key !=
'parent')) {
647 $this->xfIndex = $pValue;
661 $this->formulaAttributes = $pAttributes;
setValueExplicit($pValue, $pDataType)
Set the value for a cell, with the explicit data type passed to the method (bypassing any use of the ...
static splitRange($pRange)
Split range into coordinate strings.
static getValueBinder()
Get value binder to use.
setHyperlink(?Hyperlink $pHyperlink=null)
Set Hyperlink.
__construct($pValue, $pDataType, Worksheet $pSheet)
Create a new Cell.
getCoordinate()
Get cell coordinate.
setValue($pValue)
Set cell value.
static checkErrorCode($pValue)
Check a value that it is a valid error code.
getOldCalculatedValue()
Get old calculated value (cached) This returns the value last calculated by MS Excel or whichever spr...
setXfIndex($pValue)
Set index to cellXf.
__toString()
Convert to string.
setFormulaAttributes($pAttributes)
Set the formula attributes.
Validate a cell value according to its validation rules.
setDataType($pDataType)
Set cell data type.
getXfIndex()
Get index to cellXf.
hasHyperlink()
Does this cell contain a Hyperlink?
hasValidValue()
Does this cell contain valid value?
getValue()
Get cell value.
static setValueBinder(IValueBinder $binder)
Set value binder to use.
isInRange($pRange)
Is cell in a specific range?
getHyperlink()
Get Hyperlink.
isFormula()
Identify if the cell contains a formula.
rebindParent(Worksheet $parent)
Re-bind parent.
$formulaAttributes
Attributes of the formula.
setDataValidation(?DataValidation $pDataValidation=null)
Set Data validation rules.
hasDataValidation()
Does this cell contain Data validation rules?
static compareCells(self $a, self $b)
Compare 2 cells.
static checkString($pValue)
Check a string that it satisfies Excel requirements.
static getInstance(?Spreadsheet $spreadsheet=null)
Get an instance of this class.
getFormulaAttributes()
Get the formula attributes.
isInMergeRange()
Is this cell in a merge range.
getDataType()
Get cell data type.
setCalculatedValue($pValue)
Set old calculated value (cached).
isMergeRangeValueCell()
Is this cell the master (top left cell) in a merge range (that holds the actual data value)...
static rangeBoundaries($pRange)
Calculate range boundaries.
getMergeRange()
If this cell is in a merge range, then return the range.
getCalculatedValue($resetLog=true)
Get calculated cell value.
getParent()
Get cell collection.
getDataValidation()
Get Data validation rules.
getCellCollection()
Return the cell collection.
getFormattedValue()
Get cell value with formatting.
getRow()
Get cell coordinate row.
getStyle()
Get cell style.
static columnIndexFromString($pString)
Column index from string.
getWorksheet()
Get parent worksheet.
updateInCollection()
Update the cell into the cell collection.
__clone()
Implement PHP __clone to create a deep clone, not just a shallow copy.
getColumn()
Get cell coordinate column.