Ensure that values returned get getCalculatedValue aren't array values, irrespective of the returnArrayAsType setting
This commit is contained in:
parent
b15fa68fb5
commit
e5613be860
@ -134,7 +134,7 @@ class PHPExcel_Cell
|
|||||||
|
|
||||||
// Set worksheet cache
|
// Set worksheet cache
|
||||||
$this->_parent = $pSheet->getCellCacheController();
|
$this->_parent = $pSheet->getCellCacheController();
|
||||||
|
|
||||||
// Set datatype?
|
// Set datatype?
|
||||||
if ($pDataType !== NULL) {
|
if ($pDataType !== NULL) {
|
||||||
if ($pDataType == PHPExcel_Cell_DataType::TYPE_STRING2)
|
if ($pDataType == PHPExcel_Cell_DataType::TYPE_STRING2)
|
||||||
@ -273,21 +273,26 @@ class PHPExcel_Cell
|
|||||||
*/
|
*/
|
||||||
public function getCalculatedValue($resetLog = TRUE)
|
public function getCalculatedValue($resetLog = TRUE)
|
||||||
{
|
{
|
||||||
// echo 'Cell '.$this->getCoordinate().' value is a '.$this->_dataType.' with a value of '.$this->getValue().'<br />';
|
//echo 'Cell '.$this->getCoordinate().' value is a '.$this->_dataType.' with a value of '.$this->getValue().PHP_EOL;
|
||||||
if ($this->_dataType == PHPExcel_Cell_DataType::TYPE_FORMULA) {
|
if ($this->_dataType == PHPExcel_Cell_DataType::TYPE_FORMULA) {
|
||||||
try {
|
try {
|
||||||
// echo 'Cell value for '.$this->getCoordinate().' is a formula: Calculating value<br />';
|
//echo 'Cell value for '.$this->getCoordinate().' is a formula: Calculating value'.PHP_EOL;
|
||||||
$result = PHPExcel_Calculation::getInstance(
|
$result = PHPExcel_Calculation::getInstance(
|
||||||
$this->getWorksheet()->getParent()
|
$this->getWorksheet()->getParent()
|
||||||
)->calculateCellValue($this,$resetLog);
|
)->calculateCellValue($this,$resetLog);
|
||||||
// $result = $this->getParent()->getParent()->getCalculationEngine()->calculateCellValue($this,$resetLog);
|
//echo $this->getCoordinate().' calculation result is '.$result.PHP_EOL;
|
||||||
// echo $this->getCoordinate().' calculation result is '.$result.'<br />';
|
// We don't yet handle array returns
|
||||||
|
if (is_array($result)) {
|
||||||
|
while (is_array($result)) {
|
||||||
|
$result = array_pop($result);
|
||||||
|
}
|
||||||
|
}
|
||||||
} catch ( PHPExcel_Exception $ex ) {
|
} catch ( PHPExcel_Exception $ex ) {
|
||||||
if (($ex->getMessage() === 'Unable to access External Workbook') && ($this->_calculatedValue !== NULL)) {
|
if (($ex->getMessage() === 'Unable to access External Workbook') && ($this->_calculatedValue !== NULL)) {
|
||||||
// echo 'Returning fallback value of '.$this->_calculatedValue.' for cell '.$this->getCoordinate().'<br />';
|
//echo 'Returning fallback value of '.$this->_calculatedValue.' for cell '.$this->getCoordinate().PHP_EOL;
|
||||||
return $this->_calculatedValue; // Fallback for calculations referencing external files.
|
return $this->_calculatedValue; // Fallback for calculations referencing external files.
|
||||||
}
|
}
|
||||||
// echo 'Calculation Exception: '.$ex->getMessage().'<br />';
|
//echo 'Calculation Exception: '.$ex->getMessage().PHP_EOL;
|
||||||
$result = '#N/A';
|
$result = '#N/A';
|
||||||
throw(
|
throw(
|
||||||
new PHPExcel_Calculation_Exception(
|
new PHPExcel_Calculation_Exception(
|
||||||
@ -297,10 +302,10 @@ class PHPExcel_Cell
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($result === '#Not Yet Implemented') {
|
if ($result === '#Not Yet Implemented') {
|
||||||
// echo 'Returning fallback value of '.$this->_calculatedValue.' for cell '.$this->getCoordinate().'<br />';
|
//echo 'Returning fallback value of '.$this->_calculatedValue.' for cell '.$this->getCoordinate().PHP_EOL;
|
||||||
return $this->_calculatedValue; // Fallback if calculation engine does not support the formula.
|
return $this->_calculatedValue; // Fallback if calculation engine does not support the formula.
|
||||||
}
|
}
|
||||||
// echo 'Returning calculated value of '.$result.' for cell '.$this->getCoordinate().'<br />';
|
//echo 'Returning calculated value of '.$result.' for cell '.$this->getCoordinate().PHP_EOL;
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user