cellExists() and getCell() methods should support UTF-8 named cells

This commit is contained in:
MarkBaker 2022-08-04 14:38:35 +02:00
parent 06d2682c5b
commit f331bca470
4 changed files with 20 additions and 1 deletions

View File

@ -26,6 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org).
### Fixed ### Fixed
- Fully flatten an array [Issue #2955](https://github.com/PHPOffice/PhpSpreadsheet/issues/2955) [PR #2956](https://github.com/PHPOffice/PhpSpreadsheet/pull/2956) - Fully flatten an array [Issue #2955](https://github.com/PHPOffice/PhpSpreadsheet/issues/2955) [PR #2956](https://github.com/PHPOffice/PhpSpreadsheet/pull/2956)
- cellExists() and getCell() methods should support UTF-8 named cells [Issue #2987](https://github.com/PHPOffice/PhpSpreadsheet/issues/2987) [PR #2988](https://github.com/PHPOffice/PhpSpreadsheet/pull/2988)
## 1.24.1 - 2022-07-18 ## 1.24.1 - 2022-07-18

View File

@ -1265,7 +1265,7 @@ class Worksheet implements IComparable
} }
} elseif ( } elseif (
!preg_match('/^' . Calculation::CALCULATION_REGEXP_CELLREF . '$/i', $coordinate) && !preg_match('/^' . Calculation::CALCULATION_REGEXP_CELLREF . '$/i', $coordinate) &&
preg_match('/^' . Calculation::CALCULATION_REGEXP_DEFINEDNAME . '$/i', $coordinate) preg_match('/^' . Calculation::CALCULATION_REGEXP_DEFINEDNAME . '$/iu', $coordinate)
) { ) {
// Named range? // Named range?
$namedRange = $this->validateNamedRange($coordinate, true); $namedRange = $this->validateNamedRange($coordinate, true);

View File

@ -29,6 +29,15 @@ class WorksheetNamedRangesTest extends TestCase
self::assertTrue($cellExists); self::assertTrue($cellExists);
} }
public function testCellExistsUtf8(): void
{
$namedCell = 'Χαιρετισμός';
$worksheet = $this->spreadsheet->getActiveSheet();
$cellExists = $worksheet->cellExists($namedCell);
self::assertTrue($cellExists);
}
public function testCellNotExists(): void public function testCellNotExists(): void
{ {
$namedCell = 'GOODBYE'; $namedCell = 'GOODBYE';
@ -67,6 +76,15 @@ class WorksheetNamedRangesTest extends TestCase
self::assertSame('Hello', $cell->getValue()); self::assertSame('Hello', $cell->getValue());
} }
public function testGetCellUtf8(): void
{
$namedCell = 'Χαιρετισμός';
$worksheet = $this->spreadsheet->getActiveSheet();
$cell = $worksheet->getCell($namedCell);
self::assertSame('नमस्ते', $cell->getValue());
}
public function testGetCellNotExists(): void public function testGetCellNotExists(): void
{ {
$namedCell = 'GOODBYE'; $namedCell = 'GOODBYE';