Basic unit test and fix for loading data validations from xlsx file (#1063)

This commit is contained in:
Mark Baker 2019-07-08 19:55:14 +02:00 committed by GitHub
parent d4eab49815
commit d8047b071b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 1 deletions

View File

@ -19,7 +19,7 @@ class DataValidations
public function load() public function load()
{ {
foreach ($this->worksheetXml->dataValidation as $dataValidation) { foreach ($this->worksheetXml->dataValidations->dataValidation as $dataValidation) {
// Uppercase coordinate // Uppercase coordinate
$range = strtoupper($dataValidation['sqref']); $range = strtoupper($dataValidation['sqref']);
$rangeSet = explode(' ', $range); $rangeSet = explode(' ', $range);

View File

@ -158,6 +158,17 @@ class XlsxTest extends TestCase
$this->assertInstanceOf(Style::class, $conditionalRule->getStyle()); $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. * Test load Xlsx file without cell reference.
* *

Binary file not shown.