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) {
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);
633 if (strpos($pCoordinateString,
':') === FALSE && strpos($pCoordinateString,
',') === FALSE) {
636 $cellAddress = explode(
'!',$pCoordinateString);
637 if (count($cellAddress) > 1) {
638 list(
$worksheet,$pCoordinateString) = $cellAddress;
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);
715 $pRange = strtoupper($pRange);
718 if (strpos($pRange,
':') === FALSE) {
719 $rangeA = $rangeB = $pRange;
721 list($rangeA, $rangeB) = explode(
':', $pRange);
732 return array($rangeStart, $rangeEnd);
746 return array( ($rangeEnd[0] - $rangeStart[0] + 1), ($rangeEnd[1] - $rangeStart[1] + 1) );
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;
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) {
907 return array_values($sortKeys);
923 } elseif (self::columnIndexFromString($a->
getColumn()) < self::columnIndexFromString($b->
getColumn())) {
936 if (self::$_valueBinder === NULL) {
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;
sprintf('%.4f', $callTime)
An exception for terminatinating execution or to throw for unit testing.
static getInstance(PHPExcel $workbook=NULL)
Get an instance of this class.
static checkString($pValue=null)
Check a string that it satisfies Excel requirements.
static checkErrorCode($pValue=null)
Check a value that it is a valid error code.
getRow()
Get cell coordinate row.
setCalculatedValue($pValue=NULL)
Set old calculated value (cached)
getParent()
Get parent worksheet.
isMergeRangeValueCell()
Is this cell the master (top left cell) in a merge range (that holds the actual data value)
getOldCalculatedValue()
Get old calculated value (cached) This returns the value last calculated by MS Excel or whichever spr...
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 absoluteCoordinate($pCoordinateString='A1')
Make string coordinate absolute.
static buildRange($pRange)
Build range from coordinate strings.
getCalculatedValue($resetLog=TRUE)
Get calculated cell value.
static setValueBinder(PHPExcel_Cell_IValueBinder $binder=NULL)
Set value binder to use.
getDataValidation()
Get Data validation rules.
setFormulaAttributes($pAttributes)
getDataType()
Get cell data type.
getValue()
Get cell value.
__toString()
Convert to string.
__clone()
Implement PHP __clone to create a deep clone, not just a shallow copy.
rebindParent(PHPExcel_Worksheet $parent)
Re-bind parent.
notifyCacheController()
Send notification to the cache controller.
static getRangeBoundaries($pRange='A1:A1')
Calculate range boundaries.
static extractAllCellReferencesInRange($pRange='A1')
Extract all cell references in range.
static rangeDimension($pRange='A1:A1')
Calculate range dimension.
static stringFromColumnIndex($pColumnIndex=0)
String from columnindex.
getXfIndex()
Get index to cellXf.
getStyle()
Get cell style.
getHyperlink()
Get Hyperlink.
static coordinateFromString($pCoordinateString='A1')
Coordinate from string.
isFormula()
Identify if the cell contains a formula.
getWorksheet()
Get parent worksheet.
static getValueBinder()
Get value binder to use.
setDataValidation(PHPExcel_Cell_DataValidation $pDataValidation=NULL)
Set Data validation rules.
getColumn()
Get cell coordinate column.
static compareCells(PHPExcel_Cell $a, PHPExcel_Cell $b)
Compare 2 cells.
hasHyperlink()
Does this cell contain a Hyperlink?
isInMergeRange()
Is this cell in a merge range.
hasDataValidation()
Does this cell contain Data validation rules?
__construct($pValue=NULL, $pDataType=NULL, PHPExcel_Worksheet $pSheet=NULL)
Create a new Cell.
setDataType($pDataType=PHPExcel_Cell_DataType::TYPE_STRING)
Set cell data type.
static rangeBoundaries($pRange='A1:A1')
Calculate range boundaries.
setValue($pValue=NULL)
Set cell value.
getFormattedValue()
Get cell value with formatting.
attach(PHPExcel_CachedObjectStorage_CacheBase $parent)
getCoordinate()
Get cell coordinate.
getMergeRange()
If this cell is in a merge range, then return the range.
isInRange($pRange='A1:A1')
Is cell in a specific range?
static absoluteReference($pCoordinateString='A1')
Make string row, column or cell coordinate absolute.
setHyperlink(PHPExcel_Cell_Hyperlink $pHyperlink=NULL)
Set Hyperlink.
$_formulaAttributes
Attributes of the formula.
static splitRange($pRange='A1:A1')
Split range into coordinate strings.
setXfIndex($pValue=0)
Set index to cellXf.
static columnIndexFromString($pString='A')
Column index from string.
getCellCacheController()
Return the cache controller for the cell collection.