diff --git a/src/PhpSpreadsheet/Reader/Xls.php b/src/PhpSpreadsheet/Reader/Xls.php index 402fea9f..d1f14ae1 100644 --- a/src/PhpSpreadsheet/Reader/Xls.php +++ b/src/PhpSpreadsheet/Reader/Xls.php @@ -3759,8 +3759,13 @@ class Xls extends BaseReader } else { $textRun = $richText->createTextRun($text); if (isset($fmtRuns[$i - 1])) { - $fontIndex = $fmtRuns[$i - 1]['fontIndex']; - + if ($fmtRuns[$i - 1]['fontIndex'] < 4) { + $fontIndex = $fmtRuns[$i - 1]['fontIndex']; + } else { + // this has to do with that index 4 is omitted in all BIFF versions for some stra nge reason + // check the OpenOffice documentation of the FONT record + $fontIndex = $fmtRuns[$i - 1]['fontIndex'] - 1; + } if (array_key_exists($fontIndex, $this->objFonts) === false) { $fontIndex = count($this->objFonts) - 1; } diff --git a/tests/PhpSpreadsheetTests/Reader/Xls/RichTextSizeTest.php b/tests/PhpSpreadsheetTests/Reader/Xls/RichTextSizeTest.php new file mode 100644 index 00000000..54274e8c --- /dev/null +++ b/tests/PhpSpreadsheetTests/Reader/Xls/RichTextSizeTest.php @@ -0,0 +1,22 @@ +load($filename); + $sheet = $spreadsheet->getSheetByName('橱柜门板'); + self::assertNotNull($sheet); + $text = $sheet->getCell('L15')->getValue(); + $elements = $text->getRichTextElements(); + self::assertEquals(10, $elements[2]->getFont()->getSize()); + $spreadsheet->disconnectWorksheets(); + } +} diff --git a/tests/data/Reader/XLS/RichTextFontSize.xls b/tests/data/Reader/XLS/RichTextFontSize.xls new file mode 100644 index 00000000..3edf4737 Binary files /dev/null and b/tests/data/Reader/XLS/RichTextFontSize.xls differ