Skip to content

Commit 2d05f91

Browse files
committed
fix warning when open xlsx file with thumbnail
1 parent 2f06680 commit 2d05f91

File tree

4 files changed

+48
-0
lines changed

4 files changed

+48
-0
lines changed

src/PhpSpreadsheet/Reader/Xlsx.php

+1
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ private function loadZipNonamespace(string $filename, string $ns): SimpleXMLElem
149149

150150
private const REL_TO_MAIN = [
151151
Namespaces::PURL_OFFICE_DOCUMENT => Namespaces::PURL_MAIN,
152+
Namespaces::THUMBNAIL => '',
152153
];
153154

154155
private const REL_TO_DRAWING = [

src/PhpSpreadsheet/Reader/Xlsx/Namespaces.php

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ class Namespaces
1414
// This one used in Reader\Xlsx\Properties
1515
const CORE_PROPERTIES2 = 'http://schemas.openxmlformats.org/package/2006/metadata/core-properties';
1616

17+
const THUMBNAIL = 'http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail';
18+
1719
const THEME = 'http://schemas.openxmlformats.org/package/2006/relationships/theme';
1820

1921
const COMPATIBILITY = 'http://schemas.openxmlformats.org/markup-compatibility/2006';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
3+
namespace PhpOffice\PhpSpreadsheetTests\Reader\Xlsx;
4+
5+
use PhpOffice\PhpSpreadsheet\Reader\Xlsx;
6+
use PHPUnit\Framework\TestCase;
7+
8+
class Issue2516Test extends TestCase
9+
{
10+
/**
11+
* @var string
12+
*/
13+
private static $testbook = 'tests/data/Reader/XLSX/issue.2516b.xlsx';
14+
15+
public function testPreliminaries(): void
16+
{
17+
$file = 'zip://';
18+
$file .= self::$testbook;
19+
$file .= '#docProps/thumbnail.wmf';
20+
$data = file_get_contents($file);
21+
22+
// confirm that file exists
23+
self::assertNotFalse($data, 'thumbnail.wmf not exists');
24+
25+
$file = 'zip://';
26+
$file .= self::$testbook;
27+
$file .= '#_rels/.rels';
28+
$data = file_get_contents($file);
29+
// confirm that file contains expected namespaced xml tag
30+
if ($data === false) {
31+
self::fail('Unable to read file .rels');
32+
} else {
33+
self::assertStringContainsString('Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail" Target="docProps/thumbnail.wmf"', $data);
34+
}
35+
}
36+
37+
public function testIssue2516(): void
38+
{
39+
$filename = self::$testbook;
40+
$reader = new Xlsx();
41+
$names = $reader->listWorksheetNames($filename);
42+
$expected = ['Sheet1'];
43+
self::assertSame($expected, $names);
44+
}
45+
}
13.6 KB
Binary file not shown.

0 commit comments

Comments
 (0)