Skip to content

Commit

Permalink
Merge branches 'PHPOffice#179-unicode_namedRange', 'PHPOffice#269-cal…
Browse files Browse the repository at this point in the history
…cEngine_errors' and 'PHPOffice#388-Xlsx_MSextensions' into develop-merges
  • Loading branch information
Frederic Delaunay committed Mar 14, 2018
3 parents 7378feb + 20849c9 + 5ffcb20 commit 69e59f8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/PhpSpreadsheet/Calculation/Calculation.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ class Calculation
* @var string
*/
public $formulaError;
public $formulaErrorDetails = [];

/**
* An array of the nested cell references accessed by the calculation engine, used for the debug log.
Expand Down Expand Up @@ -2634,6 +2635,7 @@ public function calculateFormula($formula, $cellID = null, Cell $pCell = null)
{
// Initialise the logging settings
$this->formulaError = null;
$this->formulaErrorDetails = [];
$this->debugLog->clearLog();
$this->cyclicReferenceStack->clear();

Expand Down Expand Up @@ -3799,6 +3801,8 @@ private function processTokenStack($tokens, $cellID = null, Cell $pCell = null)
$pCell->attach($pCellParent);
$this->debugLog->writeDebugLog('Evaluation Result for named range ', $namedRange, ' is ', $this->showTypeDetails($cellValue));
$stack->push('Named Range', $cellValue, $namedRange);
if ($cellValue === Functions::REF())
$this->formulaErrorDetails[] = $stack->last();
} else {
return $this->raiseFormulaError("undefined variable '$token'");
}
Expand Down
15 changes: 15 additions & 0 deletions src/PhpSpreadsheet/Reader/Xlsx.php
Original file line number Diff line number Diff line change
Expand Up @@ -1239,6 +1239,21 @@ public function load($pFilename)
}

if ($xmlSheet && $xmlSheet->dataValidations && !$this->readDataOnly) {
// handle Microsoft extension if present
if (isset ($xmlSheet->extLst, $xmlSheet->extLst->ext, $xmlSheet->extLst->ext['uri'])
&& $xmlSheet->extLst->ext['uri'] == "{CCE6A557-97BC-4b89-ADB6-D9C93CAAB3DF}" )
{
// retreive MS extension data to create a node that matches expectations.
foreach ($xmlSheet->extLst->ext->children('x14', TRUE)->dataValidations->dataValidation as $item)
{
$node = $xmlSheet->dataValidations->addChild('dataValidation');
foreach ($item->attributes() as $attr)
$node->addAttribute($attr->getName(), $attr);
$node->addAttribute('sqref', $item->children('xm',TRUE)->sqref);
$node->addChild('formula1', $item->formula1->children('xm',TRUE)->f);
}
}

foreach ($xmlSheet->dataValidations->dataValidation as $dataValidation) {
// Uppercase coordinate
$range = strtoupper($dataValidation['sqref']);
Expand Down

0 comments on commit 69e59f8

Please sign in to comment.