Skip to content

Commit 8e50403

Browse files
committed
More Tweaks
1 parent 2250a0e commit 8e50403

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

src/PhpSpreadsheet/Reader/Gnumeric.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ private function processDefinedNames(?SimpleXMLElement $gnmXML): void
517517
continue;
518518
}
519519

520-
$value = str_replace("\\'", "'", $value);
520+
$value = str_replace("\\'", "''", $value);
521521
[$worksheetName] = Worksheet::extractSheetTitle($value, true, true);
522522
$worksheet = $this->spreadsheet->getSheetByName($worksheetName);
523523
// Worksheet might still be null if we're only loading selected sheets rather than the full spreadsheet

tests/PhpSpreadsheetTests/Reader/Xlsx/ApostropheTest.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,16 @@ public function testApostropheInSheetName(): void
1919
Calculation::RETURN_ARRAY_AS_ARRAY
2020
);
2121
$sheet = $spreadsheet->getActiveSheet();
22+
$sheet->setTitle('sheet1');
2223
$sheet->getCell('A1')->setValue(1);
2324
$sheet->getCell('A2')->setValue(2);
2425
$sheet->getCell('A3')->setValue(3);
2526
$sheet->getCell('A4')->setValue(4);
2627
$spreadsheet->addNamedRange(new NamedRange('sheet14cells', $sheet, '$A$1:$A$4'));
2728
$sheet->getCell('C1')
2829
->setValue('=sheet14cells*sheet14cells');
29-
$sheet->getCell('E1')->setValue('=ANCHORARRAY(C1)');
30-
$sheet->getCell('G1')->setValue('=SINGLE(C1)');
30+
$sheet->getCell('E1')->setValue('=ANCHORARRAY(sheet1!C1)');
31+
$sheet->getCell('G1')->setValue('=SINGLE(sheet1!C1:C4)');
3132

3233
$sheet1 = $spreadsheet->createSheet();
3334
$sheet1->setTitle("Apo'strophe");
@@ -38,8 +39,8 @@ public function testApostropheInSheetName(): void
3839
$spreadsheet->addNamedRange(new NamedRange('sheet24cells', $sheet1, '$A$1:$A$4'));
3940
$sheet1->getCell('C1')
4041
->setValue('=sheet24cells*sheet24cells');
41-
$sheet1->getCell('E1')->setValue('=ANCHORARRAY(C1)');
42-
$sheet1->getCell('G1')->setValue('=SINGLE(C1)');
42+
$sheet1->getCell('E1')->setValue("=ANCHORARRAY('Apo''strophe'!C1)");
43+
$sheet1->getCell('G1')->setValue("=SINGLE('Apo''strophe'!C1:C4)");
4344

4445
$reloadedSpreadsheet = $this->writeAndReload($spreadsheet, 'Xlsx');
4546
$spreadsheet->disconnectWorksheets();
@@ -48,11 +49,17 @@ public function testApostropheInSheetName(): void
4849
Calculation::RETURN_ARRAY_AS_ARRAY
4950
);
5051
$rsheet = $reloadedSpreadsheet->getSheet(0);
52+
// make sure results aren't from cache
53+
$rsheet->getCell('E1')->setCalculatedValue(-1);
54+
$rsheet->getCell('G1')->setCalculatedValue(-1);
5155
self::assertSame([[1], [4], [9], [16]], $rsheet->getCell('C1')->getCalculatedValue());
5256
self::assertSame([[1], [4], [9], [16]], $rsheet->getCell('E1')->getCalculatedValue());
5357
self::assertSame(1, $rsheet->getCell('G1')->getCalculatedValue());
5458

5559
$rsheet1 = $reloadedSpreadsheet->getSheet(1);
60+
// make sure results aren't from cache
61+
$rsheet1->getCell('E1')->setCalculatedValue(-1);
62+
$rsheet1->getCell('G1')->setCalculatedValue(-1);
5663
self::assertSame([[4], [9], [16], [25]], $rsheet1->getCell('C1')->getCalculatedValue());
5764
self::assertSame([[4], [9], [16], [25]], $rsheet1->getCell('E1')->getCalculatedValue());
5865
self::assertSame(4, $rsheet1->getCell('G1')->getCalculatedValue());

0 commit comments

Comments
 (0)