diff --git a/src/PhpSpreadsheet/Reader/Xlsx/DataValidations.php b/src/PhpSpreadsheet/Reader/Xlsx/DataValidations.php index fab702b1..4bb44129 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx/DataValidations.php +++ b/src/PhpSpreadsheet/Reader/Xlsx/DataValidations.php @@ -19,7 +19,7 @@ class DataValidations public function load() { - foreach ($this->worksheetXml->dataValidation as $dataValidation) { + foreach ($this->worksheetXml->dataValidations->dataValidation as $dataValidation) { // Uppercase coordinate $range = strtoupper($dataValidation['sqref']); $rangeSet = explode(' ', $range); diff --git a/tests/PhpSpreadsheetTests/Reader/XlsxTest.php b/tests/PhpSpreadsheetTests/Reader/XlsxTest.php index e9ab52de..5cf6f93f 100644 --- a/tests/PhpSpreadsheetTests/Reader/XlsxTest.php +++ b/tests/PhpSpreadsheetTests/Reader/XlsxTest.php @@ -158,6 +158,17 @@ class XlsxTest extends TestCase $this->assertInstanceOf(Style::class, $conditionalRule->getStyle()); } + public function testLoadXlsxDataValidation() + { + $filename = './data/Reader/XLSX/dataValidationTest.xlsx'; + $reader = new Xlsx(); + $spreadsheet = $reader->load($filename); + + $worksheet = $spreadsheet->getActiveSheet(); + + $this->assertTrue($worksheet->getCell('B3')->hasDataValidation()); + } + /** * Test load Xlsx file without cell reference. * diff --git a/tests/data/Reader/XLSX/dataValidationTest.xlsx b/tests/data/Reader/XLSX/dataValidationTest.xlsx new file mode 100644 index 00000000..b8fb7e6f Binary files /dev/null and b/tests/data/Reader/XLSX/dataValidationTest.xlsx differ