File tree Expand file tree Collapse file tree 3 files changed +26
-1
lines changed
src/PhpSpreadsheet/Reader
PhpSpreadsheetTests/Reader/Xls Expand file tree Collapse file tree 3 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -2116,7 +2116,9 @@ private function readXf(): void
2116
2116
// check the OpenOffice documentation of the FONT record
2117
2117
$ fontIndex = self ::getUInt2d ($ recordData , 0 ) - 1 ;
2118
2118
}
2119
- $ objStyle ->setFont ($ this ->objFonts [$ fontIndex ]);
2119
+ if (isset ($ this ->objFonts [$ fontIndex ])) {
2120
+ $ objStyle ->setFont ($ this ->objFonts [$ fontIndex ]);
2121
+ }
2120
2122
2121
2123
// offset: 2; size: 2; Index to FORMAT record
2122
2124
$ numberFormatIndex = self ::getUInt2d ($ recordData , 2 );
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ declare (strict_types=1 );
4
+
5
+ namespace PhpOffice \PhpSpreadsheetTests \Reader \Xls ;
6
+
7
+ use PhpOffice \PhpSpreadsheet \IOFactory ;
8
+ use PHPUnit \Framework \TestCase ;
9
+
10
+ class XlsBugPr3734Test extends TestCase
11
+ {
12
+ /**
13
+ * Test XLS file including data with missing fonts?
14
+ */
15
+ public function testXlsFileWithNoFontIndex (): void
16
+ {
17
+ $ fileName = 'tests/data/Reader/XLS/bug-pr-3734.xls ' ;
18
+ $ spreadsheet = IOFactory::load ($ fileName );
19
+ $ sheet = $ spreadsheet ->getActiveSheet ();
20
+ self ::assertSame ('Calibri ' , $ sheet ->getStyle ('A1 ' )->getFont ()->getName ());
21
+ $ spreadsheet ->disconnectWorksheets ();
22
+ }
23
+ }
You can’t perform that action at this time.
0 commit comments