106 $this->_parent->updateCacheData($this);
112 $this->_parent = NULL;
116 $this->_parent = $parent;
131 $this->_value = $pValue;
134 $this->_parent = $pSheet->getCellCacheController();
137 if ($pDataType !== NULL) {
140 $this->_dataType = $pDataType;
141 } elseif (!self::getValueBinder()->bindValue($this, $pValue)) {
153 return $this->_parent->getCurrentColumn();
163 return $this->_parent->getCurrentRow();
173 return $this->_parent->getCurrentAddress();
196 ->getNumberFormat()->getFormatCode()
211 if (!self::getValueBinder()->bindValue($this, $pValue)) {
228 switch ($pDataType) {
230 $this->_value = $pValue;
239 $this->_value = (float)$pValue;
242 $this->_value = (
string)$pValue;
245 $this->_value = (bool)$pValue;
256 $this->_dataType = $pDataType;
278 )->calculateCellValue($this,$resetLog);
287 if (($ex->getMessage() ===
'Unable to access External Workbook') && ($this->_calculatedValue !== NULL)) {
298 if (
$result ===
'#Not Yet Implemented') {
306 return $this->_value->getPlainText();
320 if ($pValue !== NULL) {
321 $this->_calculatedValue = (is_numeric($pValue)) ? (
float) $pValue : $pValue;
363 $this->_dataType = $pDataType;
386 if (!isset($this->_parent)) {
387 throw new PHPExcel_Exception(
'Cannot check for data validation when cell is not bound to a worksheet');
401 if (!isset($this->_parent)) {
402 throw new PHPExcel_Exception(
'Cannot get data validation for cell that is not bound to a worksheet');
417 if (!isset($this->_parent)) {
418 throw new PHPExcel_Exception(
'Cannot set data validation for cell that is not bound to a worksheet');
434 if (!isset($this->_parent)) {
435 throw new PHPExcel_Exception(
'Cannot check for hyperlink when cell is not bound to a worksheet');
449 if (!isset($this->_parent)) {
450 throw new PHPExcel_Exception(
'Cannot get hyperlink for cell that is not bound to a worksheet');
465 if (!isset($this->_parent)) {
466 throw new PHPExcel_Exception(
'Cannot set hyperlink for cell that is not bound to a worksheet');
489 return $this->_parent->getParent();
509 list($startCell) = $mergeRange[0];
523 foreach($this->
getWorksheet()->getMergeCells() as $mergeRange) {
561 list($rangeStart,$rangeEnd) = self::rangeBoundaries($pRange);
564 $myColumn = self::columnIndexFromString($this->
getColumn());
568 return (($rangeStart[0] <= $myColumn) && ($rangeEnd[0] >= $myColumn) &&
569 ($rangeStart[1] <= $myRow) && ($rangeEnd[1] >= $myRow)
582 if (preg_match(
"/^([$]?[A-Z]{1,3})([$]?\d{1,7})$/", $pCoordinateString, $matches)) {
583 return array($matches[1],$matches[2]);
584 } elseif ((strpos($pCoordinateString,
':') !== FALSE) || (strpos($pCoordinateString,
',') !== FALSE)) {
586 } elseif ($pCoordinateString ==
'') {
603 if (strpos($pCoordinateString,
':') === FALSE && strpos($pCoordinateString,
',') === FALSE) {
606 $cellAddress = explode(
'!',$pCoordinateString);
607 if (count($cellAddress) > 1) {
608 list(
$worksheet,$pCoordinateString) = $cellAddress;
613 if (ctype_digit($pCoordinateString)) {
615 } elseif (ctype_alpha($pCoordinateString)) {
616 return $worksheet .
'$' . strtoupper($pCoordinateString);
618 return $worksheet . self::absoluteCoordinate($pCoordinateString);
633 if (strpos($pCoordinateString,
':') === FALSE && strpos($pCoordinateString,
',') === FALSE) {
636 $cellAddress = explode(
'!',$pCoordinateString);
637 if (count($cellAddress) > 1) {
638 list(
$worksheet,$pCoordinateString) = $cellAddress;
643 list(
$column,
$row) = self::coordinateFromString($pCoordinateString);
664 $pRange = self::DEFAULT_RANGE;
667 $exploded = explode(
',', $pRange);
670 $exploded[
$i] = explode(
':', $exploded[
$i]);
685 if (!is_array($pRange) || empty($pRange) || !is_array($pRange[0])) {
693 $pRange[
$i] = implode(
':', $pRange[
$i]);
695 $imploded = implode(
',', $pRange);
711 $pRange = self::DEFAULT_RANGE;
715 $pRange = strtoupper($pRange);
718 if (strpos($pRange,
':') === FALSE) {
719 $rangeA = $rangeB = $pRange;
721 list($rangeA, $rangeB) = explode(
':', $pRange);
725 $rangeStart = self::coordinateFromString($rangeA);
726 $rangeEnd = self::coordinateFromString($rangeB);
729 $rangeStart[0] = self::columnIndexFromString($rangeStart[0]);
730 $rangeEnd[0] = self::columnIndexFromString($rangeEnd[0]);
732 return array($rangeStart, $rangeEnd);
744 list($rangeStart,$rangeEnd) = self::rangeBoundaries($pRange);
746 return array( ($rangeEnd[0] - $rangeStart[0] + 1), ($rangeEnd[1] - $rangeStart[1] + 1) );
760 $pRange = self::DEFAULT_RANGE;
764 $pRange = strtoupper($pRange);
767 if (strpos($pRange,
':') === FALSE) {
768 $rangeA = $rangeB = $pRange;
770 list($rangeA, $rangeB) = explode(
':', $pRange);
773 return array( self::coordinateFromString($rangeA), self::coordinateFromString($rangeB));
787 static $_indexCache =
array();
789 if (isset($_indexCache[$pString]))
790 return $_indexCache[$pString];
795 static $_columnLookup =
array(
796 'A' => 1,
'B' => 2,
'C' => 3,
'D' => 4,
'E' => 5,
'F' => 6,
'G' => 7,
'H' => 8,
'I' => 9,
'J' => 10,
'K' => 11,
'L' => 12,
'M' => 13,
797 'N' => 14,
'O' => 15,
'P' => 16,
'Q' => 17,
'R' => 18,
'S' => 19,
'T' => 20,
'U' => 21,
'V' => 22,
'W' => 23,
'X' => 24,
'Y' => 25,
'Z' => 26,
798 'a' => 1,
'b' => 2,
'c' => 3,
'd' => 4,
'e' => 5,
'f' => 6,
'g' => 7,
'h' => 8,
'i' => 9,
'j' => 10,
'k' => 11,
'l' => 12,
'm' => 13,
799 'n' => 14,
'o' => 15,
'p' => 16,
'q' => 17,
'r' => 18,
's' => 19,
't' => 20,
'u' => 21,
'v' => 22,
'w' => 23,
'x' => 24,
'y' => 25,
'z' => 26
804 if (isset($pString{0})) {
805 if (!isset($pString{1})) {
806 $_indexCache[$pString] = $_columnLookup[$pString];
807 return $_indexCache[$pString];
808 } elseif(!isset($pString{2})) {
809 $_indexCache[$pString] = $_columnLookup[$pString{0}] * 26 + $_columnLookup[$pString{1}];
810 return $_indexCache[$pString];
811 } elseif(!isset($pString{3})) {
812 $_indexCache[$pString] = $_columnLookup[$pString{0}] * 676 + $_columnLookup[$pString{1}] * 26 + $_columnLookup[$pString{2}];
813 return $_indexCache[$pString];
816 throw new PHPExcel_Exception(
"Column string index can not be " . ((isset($pString{0})) ?
"longer than 3 characters" :
"empty"));
830 static $_indexCache =
array();
832 if (!isset($_indexCache[$pColumnIndex])) {
834 if ($pColumnIndex < 26) {
835 $_indexCache[$pColumnIndex] = chr(65 + $pColumnIndex);
836 } elseif ($pColumnIndex < 702) {
837 $_indexCache[$pColumnIndex] = chr(64 + ($pColumnIndex / 26)) .
838 chr(65 + $pColumnIndex % 26);
840 $_indexCache[$pColumnIndex] = chr(64 + (($pColumnIndex - 26) / 676)) .
841 chr(65 + ((($pColumnIndex - 26) % 676) / 26)) .
842 chr(65 + $pColumnIndex % 26);
845 return $_indexCache[$pColumnIndex];
856 $returnValue =
array();
859 $cellBlocks = explode(
' ', str_replace(
'$',
'', strtoupper($pRange)));
860 foreach ($cellBlocks as $cellBlock) {
862 if (strpos($cellBlock,
':') === FALSE && strpos($cellBlock,
',') === FALSE) {
863 $returnValue[] = $cellBlock;
868 $ranges = self::splitRange($cellBlock);
869 foreach($ranges as $range) {
871 if (!isset($range[1])) {
872 $returnValue[] = $range[0];
877 list($rangeStart, $rangeEnd) = $range;
878 sscanf($rangeStart,
'%[A-Z]%d', $startCol, $startRow);
879 sscanf($rangeEnd,
'%[A-Z]%d', $endCol, $endRow);
883 $currentCol = $startCol;
884 $currentRow = $startRow;
887 while ($currentCol != $endCol) {
888 while ($currentRow <= $endRow) {
889 $returnValue[] = $currentCol.$currentRow;
893 $currentRow = $startRow;
900 foreach (array_unique($returnValue) as $coord) {
902 $sortKeys[sprintf(
'%3s%09d',
$column,
$row)] = $coord;
907 return array_values($sortKeys);
923 } elseif (self::columnIndexFromString($a->
getColumn()) < self::columnIndexFromString($b->
getColumn())) {
936 if (self::$_valueBinder === NULL) {
940 return self::$_valueBinder;
950 if ($binder === NULL) {
951 throw new PHPExcel_Exception(
"A PHPExcel_Cell_IValueBinder is required for PHPExcel to function correctly.");
954 self::$_valueBinder = $binder;
961 $vars = get_object_vars($this);
962 foreach ($vars as
$key => $value) {
963 if ((is_object($value)) && (
$key !=
'_parent')) {
964 $this->
$key = clone $value;
966 $this->
$key = $value;
989 $this->_xfIndex = $pValue;
999 $this->_formulaAttributes = $pAttributes;
static splitRange($pRange='A1:A1')
Split range into coordinate strings.
setFormulaAttributes($pAttributes)
static coordinateFromString($pCoordinateString='A1')
Coordinate from string.
setDataType($pDataType=PHPExcel_Cell_DataType::TYPE_STRING)
Set cell data type.
static compareCells(PHPExcel_Cell $a, PHPExcel_Cell $b)
Compare 2 cells.
getFormattedValue()
Get cell value with formatting.
static absoluteCoordinate($pCoordinateString='A1')
Make string coordinate absolute.
__toString()
Convert to string.
setXfIndex($pValue=0)
Set index to cellXf.
static rangeDimension($pRange='A1:A1')
Calculate range dimension.
static rangeBoundaries($pRange='A1:A1')
Calculate range boundaries.
static setValueBinder(PHPExcel_Cell_IValueBinder $binder=NULL)
Set value binder to use.
isInMergeRange()
Is this cell in a merge range.
getColumn()
Get cell coordinate column.
__construct($pValue=NULL, $pDataType=NULL, PHPExcel_Worksheet $pSheet=NULL)
Create a new Cell.
__clone()
Implement PHP __clone to create a deep clone, not just a shallow copy.
getStyle()
Get cell style.
hasDataValidation()
Does this cell contain Data validation rules?
isFormula()
Identify if the cell contains a formula.
rebindParent(PHPExcel_Worksheet $parent)
Re-bind parent.
static checkString($pValue=null)
Check a string that it satisfies Excel requirements.
static getValueBinder()
Get value binder to use.
getHyperlink()
Get Hyperlink.
getCoordinate()
Get cell coordinate.
getCalculatedValue($resetLog=TRUE)
Get calculated cell value.
setDataValidation(PHPExcel_Cell_DataValidation $pDataValidation=NULL)
Set Data validation rules.
static buildRange($pRange)
Build range from coordinate strings.
setHyperlink(PHPExcel_Cell_Hyperlink $pHyperlink=NULL)
Set Hyperlink.
getXfIndex()
Get index to cellXf.
setCalculatedValue($pValue=NULL)
Set old calculated value (cached)
getValue()
Get cell value.
isMergeRangeValueCell()
Is this cell the master (top left cell) in a merge range (that holds the actual data value) ...
$_formulaAttributes
Attributes of the formula.
getMergeRange()
If this cell is in a merge range, then return the range.
isInRange($pRange='A1:A1')
Is cell in a specific range?
hasHyperlink()
Does this cell contain a Hyperlink?
Create styles array
The data for the language used.
attach(PHPExcel_CachedObjectStorage_CacheBase $parent)
getDataValidation()
Get Data validation rules.
static extractAllCellReferencesInRange($pRange='A1')
Extract all cell references in range.
static columnIndexFromString($pString='A')
Column index from string.
static getRangeBoundaries($pRange='A1:A1')
Calculate range boundaries.
static getInstance(PHPExcel $workbook=NULL)
Get an instance of this class.
setValueExplicit($pValue=NULL, $pDataType=PHPExcel_Cell_DataType::TYPE_STRING)
Set the value for a cell, with the explicit data type passed to the method (bypassing any use of the ...
static stringFromColumnIndex($pColumnIndex=0)
String from columnindex.
getCellCacheController()
Return the cache controller for the cell collection.
notifyCacheController()
Send notification to the cache controller.
getDataType()
Get cell data type.
setValue($pValue=NULL)
Set cell value.
getOldCalculatedValue()
Get old calculated value (cached) This returns the value last calculated by MS Excel or whichever spr...
getParent()
Get parent worksheet.
getRow()
Get cell coordinate row.
getWorksheet()
Get parent worksheet.
static absoluteReference($pCoordinateString='A1')
Make string row, column or cell coordinate absolute.
static checkErrorCode($pValue=null)
Check a value that it is a valid error code.