Documentation

Cell
in package
implements Stringable

Table of Contents

Interfaces

Stringable

Constants

CALCULATE_DATE_TIME_ASIS  = 0
CALCULATE_DATE_TIME_FLOAT  = 1
CALCULATE_TIME_FLOAT  = 2

Properties

$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  : null|array<string, string>
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|null
Value binder to use.
$xfIndex  : int
Index to the cellXf reference for the styling of this cell.

Methods

__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.
getCalculatedValueString()  : string
Get calculated cell value converted to string.
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()  : null|array<string, string>
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.
getValueString()  : string
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.
isHiddenOnFormulaBar()  : bool
isInMergeRange()  : bool
Is this cell in a merge range.
isInRange()  : bool
Is cell in a specific range?
isLocked()  : bool
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()  : self
Set cell value.
setValueBinder()  : void
Set value binder to use.
setValueExplicit()  : self
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()  : self
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 = 0

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 null|array<string, string> $formulaAttributes = null

$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|null $valueBinder = null

$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

__construct()

Create a new Cell.

public __construct(mixed $value, string|null $dataType, Worksheet $worksheet) : mixed
Parameters
$value : mixed
$dataType : string|null
$worksheet : Worksheet
Tags
throws
Exception

__toString()

Convert to string.

public __toString() : string
Return values
string

compareCells()

Compare 2 cells.

public static compareCells(Cell $a, Cell $b) : int
Parameters
$a : Cell

Cell a

$b : Cell

Cell b

Return values
int

Result of comparison (always -1 or 1, never zero!)

detach()

public detach() : 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

Tags
throws
Exception

getCalculatedValueString()

Get calculated cell value converted to string.

public getCalculatedValueString() : string
Return values
string

getColumn()

Get cell coordinate column.

public getColumn() : string
Tags
throws
Exception
Return values
string

getCoordinate()

Get cell coordinate.

public getCoordinate() : string
Tags
throws
Exception
Return values
string

getDataType()

Get cell data type.

public getDataType() : string
Return values
string

getFormattedValue()

Get cell value with formatting.

public getFormattedValue() : string
Return values
string

getFormulaAttributes()

Get the formula attributes.

public getFormulaAttributes() : null|array<string, string>
Return values
null|array<string, string>

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.

getParent()

Get cell collection.

public getParent() : Cells|null
Return values
Cells|null

getRow()

Get cell coordinate row.

public getRow() : int
Tags
throws
Exception
Return values
int

getValue()

Get cell value.

public getValue() : mixed

getValueString()

public getValueString() : string
Return values
string

getXfIndex()

Get index to cellXf.

public getXfIndex() : int
Return values
int

hasDataValidation()

Does this cell contain Data validation rules?

public hasDataValidation() : bool
Tags
throws
Exception
Return values
bool

Does this cell contain a Hyperlink?

public hasHyperlink() : bool
Tags
throws
Exception
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

isHiddenOnFormulaBar()

public isHiddenOnFormulaBar() : 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

isLocked()

public isLocked() : bool
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
Tags
throws
Exception

setCalculatedValue()

Set old calculated value (cached).

public setCalculatedValue(mixed $originalValue[, bool $tryNumeric = true ]) : self
Parameters
$originalValue : mixed

Value

$tryNumeric : bool = true
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
Tags
throws
Exception
Return values
self

setFormulaAttributes()

Set the formula attributes.

public setFormulaAttributes(mixed $attributes) : $this
Parameters
$attributes : mixed

null|array<string, string>

Return values
$this

Set Hyperlink.

public setHyperlink([Hyperlink|null $hyperlink = null ]) : self
Parameters
$hyperlink : Hyperlink|null = null
Tags
throws
Exception
Return values
self

setValue()

Set cell value.

public setValue(mixed $value[, null|IValueBinder $binder = null ]) : self

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
throws
Exception
Return values
self

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 ]) : self
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.

Tags
throws
Exception
Return values
self

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() : self
Tags
throws
Exception
Return values
self

updateIfCellIsTableHeader()

protected static updateIfCellIsTableHeader(Worksheet|null $workSheet, self $cell, mixed $oldValue, mixed $newValue) : void
Parameters
$workSheet : Worksheet|null
$cell : self
$oldValue : mixed
$newValue : mixed

convertDateTimeInt()

Convert date, time, or datetime from int to float if desired.

private convertDateTimeInt(mixed $result) : mixed
Parameters
$result : mixed

        
On this page

Search results