Skip to content

Commit f1ab776

Browse files
authored
Merge pull request #4740 from oleibman/issue4739
Single Character Table Names
2 parents 0acb994 + 01f9b2a commit f1ab776

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ and this project adheres to [Semantic Versioning](https://semver.org). Thia is a
3232
- Slightly better support for escaped characters in Xlsx Reader/Writer. [Discussion #4724](https://github.com/PHPOffice/PhpSpreadsheet/discussions/4724) [PR #4726](https://github.com/PHPOffice/PhpSpreadsheet/pull/4726)
3333
- CODE/UNICODE and CHAR/UNICHAR. [PR #4727](https://github.com/PHPOffice/PhpSpreadsheet/pull/4727)
3434
- Minor changes to TextGrid. [PR #4735](https://github.com/PHPOffice/PhpSpreadsheet/pull/4735)
35+
- Single-character table names. [Issue #4739](https://github.com/PHPOffice/PhpSpreadsheet/issues/4739) [PR #4740](https://github.com/PHPOffice/PhpSpreadsheet/pull/4740)
3536

3637
## 2025-11-24 - 5.3.0
3738

src/PhpSpreadsheet/Worksheet/Table.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public function setName(string $name): self
120120
if (!preg_match('/^[\p{L}_\\\]/iu', $name)) {
121121
throw new PhpSpreadsheetException('The table name must begin a name with a letter, an underscore character (_), or a backslash (\)');
122122
}
123-
if (!preg_match('/^[\p{L}_\\\][\p{L}\p{M}0-9\._]+$/iu', $name)) {
123+
if (!preg_match('/^[\p{L}_\\\][\p{L}\p{M}0-9\._]*$/iu', $name)) {
124124
throw new PhpSpreadsheetException('The table name contains invalid characters');
125125
}
126126

tests/PhpSpreadsheetTests/Worksheet/Table/TableTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function testValidTableNames(string $name, string $expected): void
3333
$table = new Table(self::INITIAL_RANGE);
3434

3535
$result = $table->setName($name);
36-
self::assertEquals($expected, $result->getName());
36+
self::assertSame($expected, $result->getName());
3737
}
3838

3939
public static function validTableNamesProvider(): array
@@ -45,6 +45,7 @@ public static function validTableNamesProvider(): array
4545
['\table_3', '\table_3'],
4646
[" Table_4 \n", 'Table_4'],
4747
['table.5', 'table.5'],
48+
'issue 4739' => ['x', 'x'],
4849
['தமிழ்', 'தமிழ்'], // UTF-8 letters with combined character
4950
];
5051
}

0 commit comments

Comments
 (0)