74        $this->parent->update($this);
 
   99        $this->value = $pValue;
 
  102        $this->parent = $pSheet->getCellCollection();
 
  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) {
 
  545        $this->parent = 
$parent->getCellCollection();
 
  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) {
 
  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;
 
An exception for terminatinating execution or to throw for unit testing.
static getInstance(?Spreadsheet $spreadsheet=null)
Get an instance of this class.
setXfIndex($pValue)
Set index to cellXf.
getDataValidation()
Get Data validation rules.
static compareCells(self $a, self $b)
Compare 2 cells.
getFormattedValue()
Get cell value with formatting.
updateInCollection()
Update the cell into the cell collection.
getWorksheet()
Get parent worksheet.
getParent()
Get cell collection.
getMergeRange()
If this cell is in a merge range, then return the range.
__toString()
Convert to string.
__clone()
Implement PHP __clone to create a deep clone, not just a shallow copy.
setDataType($pDataType)
Set cell data type.
hasHyperlink()
Does this cell contain a Hyperlink?
hasDataValidation()
Does this cell contain Data validation rules?
getColumn()
Get cell coordinate column.
rebindParent(Worksheet $parent)
Re-bind parent.
isFormula()
Identify if the cell contains a formula.
isInRange($pRange)
Is cell in a specific range?
getCoordinate()
Get cell coordinate.
setValueExplicit($pValue, $pDataType)
Set the value for a cell, with the explicit data type passed to the method (bypassing any use of the ...
isMergeRangeValueCell()
Is this cell the master (top left cell) in a merge range (that holds the actual data value).
static setValueBinder(IValueBinder $binder)
Set value binder to use.
__construct($pValue, $pDataType, Worksheet $pSheet)
Create a new Cell.
getValue()
Get cell value.
getHyperlink()
Get Hyperlink.
static getValueBinder()
Get value binder to use.
setHyperlink(?Hyperlink $pHyperlink=null)
Set Hyperlink.
getFormulaAttributes()
Get the formula attributes.
getStyle()
Get cell style.
setCalculatedValue($pValue)
Set old calculated value (cached).
getOldCalculatedValue()
Get old calculated value (cached) This returns the value last calculated by MS Excel or whichever spr...
getRow()
Get cell coordinate row.
$formulaAttributes
Attributes of the formula.
isInMergeRange()
Is this cell in a merge range.
getDataType()
Get cell data type.
setValue($pValue)
Set cell value.
hasValidValue()
Does this cell contain valid value?
getCalculatedValue($resetLog=true)
Get calculated cell value.
setDataValidation(?DataValidation $pDataValidation=null)
Set Data validation rules.
getXfIndex()
Get index to cellXf.
setFormulaAttributes($pAttributes)
Set the formula attributes.
static columnIndexFromString($pString)
Column index from string.
static splitRange($pRange)
Split range into coordinate strings.
static rangeBoundaries($pRange)
Calculate range boundaries.
static checkErrorCode($pValue)
Check a value that it is a valid error code.
static checkString($pValue)
Check a string that it satisfies Excel requirements.
Validate a cell value according to its validation rules.