-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Theme File Missing But Referenced in Spreadsheet (#3772)
* Theme File Missing But Referenced in Spreadsheet Fix #3770. A rels file points to a non-existent theme file in the spreadsheet. In other similar cases (e.g. PR #3771), Excel opens such a spreadsheet, but with an error pop-up. Not so with this file; it just opens the spreadsheet without the pop-up. PhpSpreadsheet will now account for this unusual situation as well. * Update CHANGELOG.md
- Loading branch information
Showing
4 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PhpOffice\PhpSpreadsheetTests\Reader\Xlsx; | ||
|
||
use PhpOffice\PhpSpreadsheet\Reader\Xlsx; | ||
|
||
class Issue3770Test extends \PHPUnit\Framework\TestCase | ||
{ | ||
private static string $testbook = 'tests/data/Reader/XLSX/issue.3770.xlsx'; | ||
|
||
public function testPreliminaries(): void | ||
{ | ||
$file = 'zip://'; | ||
$file .= self::$testbook; | ||
$file .= '#xl/_rels/workbook.xml.rels'; | ||
$data = file_get_contents($file); | ||
// rels file points to non-existent theme file | ||
if ($data === false) { | ||
self::fail('Unable to read file'); | ||
} else { | ||
self::assertStringContainsString('Target="theme/theme1.xml"', $data); | ||
self::assertStringContainsString('Target="worksheets/sheet1.xml"', $data); | ||
} | ||
$file = 'zip://'; | ||
$file .= self::$testbook; | ||
$file .= '#xl/theme/theme1.xml'; | ||
$data = @file_get_contents($file); | ||
self::assertFalse($data); | ||
$file = 'zip://'; | ||
$file .= self::$testbook; | ||
$file .= '#xl/worksheets/sheet1.xml'; | ||
$data = file_get_contents($file); | ||
self::assertNotFalse($data); | ||
} | ||
|
||
public function testLoadable(): void | ||
{ | ||
$reader = new Xlsx(); | ||
$spreadsheet = $reader->load(self::$testbook); | ||
$sheet = $spreadsheet->getActiveSheet(); | ||
// Assert anything to confirm read succeeded | ||
self::assertSame('Универсальный передаточный документ', $sheet->getCell('A1')->getValue()); | ||
$spreadsheet->disconnectWorksheets(); | ||
} | ||
} |
Binary file not shown.