Skip to content

Commit d8047b0

Browse files
author
Mark Baker
authored
Basic unit test and fix for loading data validations from xlsx file (#1063)
1 parent d4eab49 commit d8047b0

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

src/PhpSpreadsheet/Reader/Xlsx/DataValidations.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public function __construct(Worksheet $workSheet, \SimpleXMLElement $worksheetXm
1919

2020
public function load()
2121
{
22-
foreach ($this->worksheetXml->dataValidation as $dataValidation) {
22+
foreach ($this->worksheetXml->dataValidations->dataValidation as $dataValidation) {
2323
// Uppercase coordinate
2424
$range = strtoupper($dataValidation['sqref']);
2525
$rangeSet = explode(' ', $range);

tests/PhpSpreadsheetTests/Reader/XlsxTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,17 @@ public function testLoadXlsxConditionalFormatting()
158158
$this->assertInstanceOf(Style::class, $conditionalRule->getStyle());
159159
}
160160

161+
public function testLoadXlsxDataValidation()
162+
{
163+
$filename = './data/Reader/XLSX/dataValidationTest.xlsx';
164+
$reader = new Xlsx();
165+
$spreadsheet = $reader->load($filename);
166+
167+
$worksheet = $spreadsheet->getActiveSheet();
168+
169+
$this->assertTrue($worksheet->getCell('B3')->hasDataValidation());
170+
}
171+
161172
/**
162173
* Test load Xlsx file without cell reference.
163174
*
6.64 KB
Binary file not shown.

0 commit comments

Comments
 (0)