Cell
Table of Contents
- CALCULATE_DATE_TIME_ASIS = 0
- CALCULATE_DATE_TIME_FLOAT = 1
- CALCULATE_TIME_FLOAT = 2
- $calculateDateTimeType : int
- $calculatedValue : mixed
- Calculated value of the cell (used for caching) This returns the value last calculated by MS Excel or whichever spreadsheet program was used to create the original spreadsheet file.
- $dataType : string
- Type of the cell data.
- $formulaAttributes : mixed
- Attributes of the formula.
- $ignoredErrors : IgnoredErrors
- $parent : Cells|null
- The collection of cells that this cell belongs to (i.e. The Cell Collection for the parent Worksheet).
- $value : mixed
- Value of the cell.
- $valueBinder : IValueBinder
- Value binder to use.
- $xfIndex : int
- Index to the cellXf reference for the styling of this cell.
- __clone() : mixed
- Implement PHP __clone to create a deep clone, not just a shallow copy.
- __construct() : mixed
- Create a new Cell.
- __toString() : string
- Convert to string.
- attach() : void
- compareCells() : int
- Compare 2 cells.
- detach() : void
- getAppliedStyle() : Style
- Get cell style.
- getCalculateDateTimeType() : int
- getCalculatedValue() : mixed
- Get calculated cell value.
- getColumn() : string
- Get cell coordinate column.
- getCoordinate() : string
- Get cell coordinate.
- getDataType() : string
- Get cell data type.
- getDataValidation() : DataValidation
- Get Data validation rules.
- getFormattedValue() : string
- Get cell value with formatting.
- getFormulaAttributes() : mixed
- Get the formula attributes.
- getHyperlink() : Hyperlink
- Get Hyperlink.
- getIgnoredErrors() : IgnoredErrors
- getMergeRange() : false|string
- If this cell is in a merge range, then return the range.
- getOldCalculatedValue() : mixed
- 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.
- getParent() : Cells|null
- Get cell collection.
- getRow() : int
- Get cell coordinate row.
- getStyle() : Style
- Get cell style.
- getValue() : mixed
- Get cell value.
- getValueBinder() : IValueBinder
- Get value binder to use.
- getWorksheet() : Worksheet
- Get parent worksheet.
- getWorksheetOrNull() : Worksheet|null
- getXfIndex() : int
- Get index to cellXf.
- hasDataValidation() : bool
- Does this cell contain Data validation rules?
- hasHyperlink() : bool
- Does this cell contain a Hyperlink?
- hasValidValue() : bool
- Does this cell contain valid value?
- isFormula() : bool
- Identify if the cell contains a formula.
- isInMergeRange() : bool
- Is this cell in a merge range.
- isInRange() : bool
- Is cell in a specific range?
- isMergeRangeValueCell() : bool
- Is this cell the master (top left cell) in a merge range (that holds the actual data value).
- rebindParent() : self
- Re-bind parent.
- setCalculateDateTimeType() : void
- setCalculatedValue() : self
- Set old calculated value (cached).
- setDataType() : self
- Set cell data type.
- setDataValidation() : self
- Set Data validation rules.
- setFormulaAttributes() : $this
- Set the formula attributes.
- setHyperlink() : self
- Set Hyperlink.
- setValue() : $this
- Set cell value.
- setValueBinder() : void
- Set value binder to use.
- setValueExplicit() : Cell
- Set the value for a cell, with the explicit data type passed to the method (bypassing any use of the value binder).
- setXfIndex() : self
- Set index to cellXf.
- updateInCollection() : $this
- Update the cell into the cell collection.
- updateIfCellIsTableHeader() : void
- convertDateTimeInt() : mixed
- Convert date, time, or datetime from int to float if desired.
Constants
CALCULATE_DATE_TIME_ASIS
public
mixed
CALCULATE_DATE_TIME_ASIS
= ""
CALCULATE_DATE_TIME_FLOAT
public
mixed
CALCULATE_DATE_TIME_FLOAT
= 1
CALCULATE_TIME_FLOAT
public
mixed
CALCULATE_TIME_FLOAT
= 2
Properties
$calculateDateTimeType
private
static int
$calculateDateTimeType
= self::CALCULATE_DATE_TIME_ASIS
$calculatedValue
Calculated value of the cell (used for caching) This returns the value last calculated by MS Excel or whichever spreadsheet program was used to create the original spreadsheet file.
private
mixed
$calculatedValue
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.
$dataType
Type of the cell data.
private
string
$dataType
$formulaAttributes
Attributes of the formula.
private
mixed
$formulaAttributes
$ignoredErrors
private
IgnoredErrors
$ignoredErrors
$parent
The collection of cells that this cell belongs to (i.e. The Cell Collection for the parent Worksheet).
private
Cells|null
$parent
$value
Value of the cell.
private
mixed
$value
$valueBinder
Value binder to use.
private
static IValueBinder
$valueBinder
$xfIndex
Index to the cellXf reference for the styling of this cell.
private
int
$xfIndex
= 0
Methods
__clone()
Implement PHP __clone to create a deep clone, not just a shallow copy.
public
__clone() : mixed
Return values
mixed —__construct()
Create a new Cell.
public
__construct(mixed $value, string|null $dataType, Worksheet $worksheet) : mixed
Parameters
- $value : mixed
- $dataType : string|null
- $worksheet : Worksheet
Return values
mixed —__toString()
Convert to string.
public
__toString() : string
Return values
string —attach()
public
attach(Cells $parent) : void
Parameters
- $parent : Cells
Return values
void —compareCells()
Compare 2 cells.
public
static compareCells(Cell $a, Cell $b) : int
Parameters
Return values
int —Result of comparison (always -1 or 1, never zero!)
detach()
public
detach() : void
Return values
void —getAppliedStyle()
Get cell style.
public
getAppliedStyle() : Style
Return values
Style —getCalculateDateTimeType()
public
static getCalculateDateTimeType() : int
Return values
int —getCalculatedValue()
Get calculated cell value.
public
getCalculatedValue([bool $resetLog = true ]) : mixed
Parameters
- $resetLog : bool = true
-
Whether the calculation engine logger should be reset or not
Return values
mixed —getColumn()
Get cell coordinate column.
public
getColumn() : string
Return values
string —getCoordinate()
Get cell coordinate.
public
getCoordinate() : string
Return values
string —getDataType()
Get cell data type.
public
getDataType() : string
Return values
string —getDataValidation()
Get Data validation rules.
public
getDataValidation() : DataValidation
Return values
DataValidation —getFormattedValue()
Get cell value with formatting.
public
getFormattedValue() : string
Return values
string —getFormulaAttributes()
Get the formula attributes.
public
getFormulaAttributes() : mixed
Return values
mixed —getHyperlink()
Get Hyperlink.
public
getHyperlink() : Hyperlink
Return values
Hyperlink —getIgnoredErrors()
public
getIgnoredErrors() : IgnoredErrors
Return values
IgnoredErrors —getMergeRange()
If this cell is in a merge range, then return the range.
public
getMergeRange() : false|string
Return values
false|string —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.
public
getOldCalculatedValue() : mixed
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.
Return values
mixed —getParent()
Get cell collection.
public
getParent() : Cells|null
Return values
Cells|null —getRow()
Get cell coordinate row.
public
getRow() : int
Return values
int —getStyle()
Get cell style.
public
getStyle() : Style
Return values
Style —getValue()
Get cell value.
public
getValue() : mixed
Return values
mixed —getValueBinder()
Get value binder to use.
public
static getValueBinder() : IValueBinder
Return values
IValueBinder —getWorksheet()
Get parent worksheet.
public
getWorksheet() : Worksheet
Return values
Worksheet —getWorksheetOrNull()
public
getWorksheetOrNull() : Worksheet|null
Return values
Worksheet|null —getXfIndex()
Get index to cellXf.
public
getXfIndex() : int
Return values
int —hasDataValidation()
Does this cell contain Data validation rules?
public
hasDataValidation() : bool
Return values
bool —hasHyperlink()
Does this cell contain a Hyperlink?
public
hasHyperlink() : bool
Return values
bool —hasValidValue()
Does this cell contain valid value?
public
hasValidValue() : bool
Return values
bool —isFormula()
Identify if the cell contains a formula.
public
isFormula() : bool
Return values
bool —isInMergeRange()
Is this cell in a merge range.
public
isInMergeRange() : bool
Return values
bool —isInRange()
Is cell in a specific range?
public
isInRange(string $range) : bool
Parameters
- $range : string
-
Cell range (e.g. A1:A1)
Return values
bool —isMergeRangeValueCell()
Is this cell the master (top left cell) in a merge range (that holds the actual data value).
public
isMergeRangeValueCell() : bool
Return values
bool —rebindParent()
Re-bind parent.
public
rebindParent(Worksheet $parent) : self
Parameters
- $parent : Worksheet
Return values
self —setCalculateDateTimeType()
public
static setCalculateDateTimeType(int $calculateDateTimeType) : void
Parameters
- $calculateDateTimeType : int
Return values
void —setCalculatedValue()
Set old calculated value (cached).
public
setCalculatedValue(mixed $originalValue) : self
Parameters
- $originalValue : mixed
-
Value
Return values
self —setDataType()
Set cell data type.
public
setDataType(string $dataType) : self
Parameters
- $dataType : string
-
see DataType::TYPE_*
Return values
self —setDataValidation()
Set Data validation rules.
public
setDataValidation([DataValidation|null $dataValidation = null ]) : self
Parameters
- $dataValidation : DataValidation|null = null
Return values
self —setFormulaAttributes()
Set the formula attributes.
public
setFormulaAttributes(mixed $attributes) : $this
Parameters
- $attributes : mixed
Return values
$this —setHyperlink()
Set Hyperlink.
public
setHyperlink([Hyperlink|null $hyperlink = null ]) : self
Parameters
- $hyperlink : Hyperlink|null = null
Return values
self —setValue()
Set cell value.
public
setValue(mixed $value[, null|IValueBinder $binder = null ]) : $this
Sets the value for a cell, automatically determining the datatype using the value binder
Parameters
- $value : mixed
-
Value
- $binder : null|IValueBinder = null
-
Value Binder to override the currently set Value Binder
Tags
Return values
$this —setValueBinder()
Set value binder to use.
public
static setValueBinder(IValueBinder $binder) : void
Parameters
- $binder : IValueBinder
Return values
void —setValueExplicit()
Set the value for a cell, with the explicit data type passed to the method (bypassing any use of the value binder).
public
setValueExplicit(mixed $value[, string $dataType = DataType::TYPE_STRING ]) : Cell
Parameters
- $value : mixed
-
Value
- $dataType : string = DataType::TYPE_STRING
-
Explicit data type, see DataType::TYPE_* Note that PhpSpreadsheet does not validate that the value and datatype are consistent, in using this method, then it is your responsibility as an end-user developer to validate that the value and the datatype match. If you do mismatch value and datatype, then the value you enter may be changed to match the datatype that you specify.
Return values
Cell —setXfIndex()
Set index to cellXf.
public
setXfIndex(int $indexValue) : self
Parameters
- $indexValue : int
Return values
self —updateInCollection()
Update the cell into the cell collection.
public
updateInCollection() : $this
Return values
$this —updateIfCellIsTableHeader()
protected
static updateIfCellIsTableHeader(Worksheet|null $workSheet, self $cell, mixed $oldValue, mixed $newValue) : void
Parameters
- $workSheet : Worksheet|null
- $cell : self
- $oldValue : mixed
- $newValue : mixed
Return values
void —convertDateTimeInt()
Convert date, time, or datetime from int to float if desired.
private
convertDateTimeInt(mixed $result) : mixed
Parameters
- $result : mixed