Skip to content

Commit ae6c92b

Browse files
committed
More Tests
1 parent 8930e63 commit ae6c92b

File tree

5 files changed

+34
-1
lines changed

5 files changed

+34
-1
lines changed

src/PhpSpreadsheet/Calculation/LookupRef/Offset.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ private static function extractWorksheet(?string $cellAddress, Cell $cell): arra
103103

104104
$sheetName = '';
105105
if (str_contains($cellAddress, '!')) {
106-
[$sheetName, $cellAddress] = Worksheet::extractSheetTitle($cellAddress, true);
106+
[$sheetName, $cellAddress] = Worksheet::extractSheetTitle($cellAddress, true, true);
107107
}
108108

109109
$worksheet = ($sheetName !== '')

src/PhpSpreadsheet/Reader/Gnumeric.php

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

520+
$value = str_replace("\\'", "'", $value);
520521
[$worksheetName] = Worksheet::extractSheetTitle($value, true, true);
521522
$worksheet = $this->spreadsheet->getSheetByName($worksheetName);
522523
// Worksheet might still be null if we're only loading selected sheets rather than the full spreadsheet
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace PhpOffice\PhpSpreadsheetTests\Reader\Gnumeric;
6+
7+
use PhpOffice\PhpSpreadsheet\Reader\Gnumeric;
8+
use PHPUnit\Framework\Attributes\DataProvider;
9+
use PHPUnit\Framework\TestCase;
10+
11+
class DefinedNameTest extends TestCase
12+
{
13+
public static function fileProvider(): array
14+
{
15+
return [
16+
['tests/data/Reader/Gnumeric/apostrophe3a.gnumeric', 'Sheet1'],
17+
['tests/data/Reader/Gnumeric/apostrophe3b.gnumeric', 'Apo\'strophe'],
18+
];
19+
}
20+
21+
#[DataProvider('fileProvider')]
22+
public function testDefinedName(string $filename, string $sheetName): void
23+
{
24+
$reader = new Gnumeric();
25+
$spreadsheet = $reader->load($filename);
26+
$sheet = $spreadsheet->getActiveSheet();
27+
self::assertSame($sheetName, $sheet->getTitle());
28+
self::assertSame('=sheet1first', $sheet->getCell('C1')->getValue());
29+
self::assertSame(1, $sheet->getCell('C1')->getCalculatedValue());
30+
$spreadsheet->disconnectWorksheets();
31+
}
32+
}
1.71 KB
Binary file not shown.
1.72 KB
Binary file not shown.

0 commit comments

Comments
 (0)