|
3 | 3 | namespace PhpOffice\PhpSpreadsheetTests\Reader;
|
4 | 4 |
|
5 | 5 | use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
|
| 6 | +use PhpOffice\PhpSpreadsheet\Cell\DataValidation; |
6 | 7 | use PhpOffice\PhpSpreadsheet\Document\Properties;
|
7 | 8 | use PhpOffice\PhpSpreadsheet\Reader\Xlsx;
|
8 | 9 | use PhpOffice\PhpSpreadsheet\Shared\File;
|
@@ -147,6 +148,31 @@ public function testLoadXlsxDataValidation(): void
|
147 | 148 | self::assertTrue($worksheet->getCell('B3')->hasDataValidation());
|
148 | 149 | }
|
149 | 150 |
|
| 151 | + /* |
| 152 | + * Test for load drop down lists of another sheet. |
| 153 | + * Pull #2150, issue #2149 |
| 154 | + */ |
| 155 | + public function testLoadXlsxDataValidationOfAnotherSheet(): void |
| 156 | + { |
| 157 | + $filename = 'tests/data/Reader/XLSX/dataValidation2Test.xlsx'; |
| 158 | + $reader = new Xlsx(); |
| 159 | + $spreadsheet = $reader->load($filename); |
| 160 | + |
| 161 | + $worksheet = $spreadsheet->getActiveSheet(); |
| 162 | + |
| 163 | + // same sheet |
| 164 | + $validationCell = $worksheet->getCell('B5'); |
| 165 | + self::assertTrue($validationCell->hasDataValidation()); |
| 166 | + self::assertSame(DataValidation::TYPE_LIST, $validationCell->getDataValidation()->getType()); |
| 167 | + self::assertSame('$A$5:$A$7', $validationCell->getDataValidation()->getFormula1()); |
| 168 | + |
| 169 | + // another sheet |
| 170 | + $validationCell = $worksheet->getCell('B14'); |
| 171 | + self::assertTrue($validationCell->hasDataValidation()); |
| 172 | + self::assertSame(DataValidation::TYPE_LIST, $validationCell->getDataValidation()->getType()); |
| 173 | + self::assertSame('Feuil2!$A$3:$A$5', $validationCell->getDataValidation()->getFormula1()); |
| 174 | + } |
| 175 | + |
150 | 176 | /**
|
151 | 177 | * Test load Xlsx file without cell reference.
|
152 | 178 | *
|
|
0 commit comments