-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix ODS read filter on number-columns-repeated cell (#3149)
- Loading branch information
Showing
3 changed files
with
50 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
tests/PhpSpreadsheetTests/Reader/Ods/RepeatedColumnsTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
namespace PhpOffice\PhpSpreadsheetTests\Reader\Ods; | ||
|
||
use PhpOffice\PhpSpreadsheet\Reader\IReadFilter; | ||
use PhpOffice\PhpSpreadsheet\Reader\Ods; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class RepeatedColumnsTest extends TestCase | ||
{ | ||
/** | ||
* @var Ods | ||
*/ | ||
private $reader; | ||
|
||
protected function setUp(): void | ||
{ | ||
$this->reader = new Ods(); | ||
} | ||
|
||
public function testDefinedNames(): void | ||
{ | ||
$this->reader->setReadFilter( | ||
new class () implements IReadFilter { | ||
public function readCell($columnAddress, $row, $worksheetName = ''): bool | ||
{ | ||
return in_array($columnAddress, ['A', 'C', 'E', 'G', 'J', 'K'], true); | ||
} | ||
} | ||
); | ||
$spreadsheet = $this->reader->load('tests/data/Reader/Ods/RepeatedCells.ods'); | ||
$worksheet = $spreadsheet->getActiveSheet(); | ||
|
||
self::assertEquals('TestA', $worksheet->getCell('A1')->getValue()); | ||
self::assertNull($worksheet->getCell('C1')->getValue()); | ||
self::assertEquals('TestE', $worksheet->getCell('E1')->getValue()); | ||
self::assertEquals('TestG', $worksheet->getCell('G1')->getValue()); | ||
self::assertEquals('A', $worksheet->getCell('J1')->getValue()); | ||
self::assertEquals('TestK', $worksheet->getCell('K1')->getValue()); | ||
} | ||
} |
Binary file not shown.