diff --git a/CHANGELOG.md b/CHANGELOG.md index 240454ef75..05dda2d384 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -67,6 +67,7 @@ and this project adheres to [Semantic Versioning](https://semver.org). - Break Some Circular References. [PR #3716](https://github.com/PHPOffice/PhpSpreadsheet/pull/3716) [PR #3707](https://github.com/PHPOffice/PhpSpreadsheet/pull/3707) - Missing Font Index in Some Xls. [PR #3734](https://github.com/PHPOffice/PhpSpreadsheet/pull/3734) - Load Tables even with READ_DATA_ONLY. [PR #3726](https://github.com/PHPOffice/PhpSpreadsheet/pull/3726) +- Theme File Missing but Referenced in Spreadsheet. [Issue #3770](https://github.com/PHPOffice/PhpSpreadsheet/issues/3770) [PR #3772](https://github.com/PHPOffice/PhpSpreadsheet/pull/3772) ## 1.29.0 - 2023-06-15 diff --git a/src/PhpSpreadsheet/Reader/Xlsx.php b/src/PhpSpreadsheet/Reader/Xlsx.php index 3c2b4f244a..99fb3937d5 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx.php +++ b/src/PhpSpreadsheet/Reader/Xlsx.php @@ -427,6 +427,9 @@ protected function loadSpreadsheetFromFile(string $filename): Spreadsheet } switch ($rel['Type']) { case "$xmlNamespaceBase/theme": + if (!$this->fileExistsInArchive($zip, "xl/{$relTarget}")) { + break; // issue3770 + } $themeOrderArray = ['lt1', 'dk1', 'lt2', 'dk2']; $themeOrderAdditional = count($themeOrderArray); diff --git a/tests/PhpSpreadsheetTests/Reader/Xlsx/Issue3770Test.php b/tests/PhpSpreadsheetTests/Reader/Xlsx/Issue3770Test.php new file mode 100644 index 0000000000..469c02e513 --- /dev/null +++ b/tests/PhpSpreadsheetTests/Reader/Xlsx/Issue3770Test.php @@ -0,0 +1,47 @@ +load(self::$testbook); + $sheet = $spreadsheet->getActiveSheet(); + // Assert anything to confirm read succeeded + self::assertSame('Универсальный передаточный документ', $sheet->getCell('A1')->getValue()); + $spreadsheet->disconnectWorksheets(); + } +} diff --git a/tests/data/Reader/XLSX/issue.3770.xlsx b/tests/data/Reader/XLSX/issue.3770.xlsx new file mode 100644 index 0000000000..415f6691d3 Binary files /dev/null and b/tests/data/Reader/XLSX/issue.3770.xlsx differ