Merge pull request #2988 from PHPOffice/Issue-2987_NamedCell-UTF8-Worksheet-getCell

cellExists() and getCell() methods should support UTF-8 named cells
This commit is contained in:
Mark Baker 2022-08-04 15:00:40 +02:00 committed by GitHub
commit 630d92f0f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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
- 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

View File

@ -1265,7 +1265,7 @@ class Worksheet implements IComparable
}
} elseif (
!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?
$namedRange = $this->validateNamedRange($coordinate, true);

View File

@ -29,6 +29,15 @@ class WorksheetNamedRangesTest extends TestCase
self::assertTrue($cellExists);
}
public function testCellExistsUtf8(): void
{
$namedCell = 'Χαιρετισμός';
$worksheet = $this->spreadsheet->getActiveSheet();
$cellExists = $worksheet->cellExists($namedCell);
self::assertTrue($cellExists);
}
public function testCellNotExists(): void
{
$namedCell = 'GOODBYE';
@ -67,6 +76,15 @@ class WorksheetNamedRangesTest extends TestCase
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
{
$namedCell = 'GOODBYE';