From 5ffcb20589a491bfcf8dffa526c7bf8eb5d9bc33 Mon Sep 17 00:00:00 2001 From: Frederic Delaunay Date: Wed, 14 Mar 2018 20:11:05 +0100 Subject: [PATCH 1/2] FIX: #388 - supporting Microsoft x14 and xm extensions for dataValidations. --- src/PhpSpreadsheet/Reader/Xlsx.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/PhpSpreadsheet/Reader/Xlsx.php b/src/PhpSpreadsheet/Reader/Xlsx.php index b54622cd37..41ced9111c 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx.php +++ b/src/PhpSpreadsheet/Reader/Xlsx.php @@ -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']); From 5b38d3d47f6bd2b6966188db954a8c99cefc6801 Mon Sep 17 00:00:00 2001 From: Frederic Delaunay Date: Fri, 16 Mar 2018 15:10:30 +0100 Subject: [PATCH 2/2] ADD: entry about added x14 and xm extensions in the dataValidation part of the Xlsx format. --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9fb42e539c..d5f7a21beb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,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)