diff --git a/CHANGELOG.md b/CHANGELOG.md index 86615d2751..34c44c9468 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -45,6 +45,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Added +- Xlsx reader supports MS x14 and xm extensions for dataValidations - [#388](https://github.com/PHPOffice/PhpSpreadsheet/issues/388) - HTML writer creates a generator meta tag - [#312](https://github.com/PHPOffice/PhpSpreadsheet/issues/312) - Support invalid zoom value in XLSX format - [#350](https://github.com/PHPOffice/PhpSpreadsheet/pull/350) - Support for `_xlfn.` prefixed functions and `ISFORMULA`, `MODE.SNGL`, `STDEV.S`, `STDEV.P` - [#390](https://github.com/PHPOffice/PhpSpreadsheet/pull/390) diff --git a/src/PhpSpreadsheet/Reader/Xlsx.php b/src/PhpSpreadsheet/Reader/Xlsx.php index 369497683e..77f520bd9a 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx.php +++ b/src/PhpSpreadsheet/Reader/Xlsx.php @@ -1334,6 +1334,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']);