File tree Expand file tree Collapse file tree 3 files changed +29
-2
lines changed
src/PhpSpreadsheet/Reader
PhpSpreadsheetTests/Reader/Xls Expand file tree Collapse file tree 3 files changed +29
-2
lines changed Original file line number Diff line number Diff line change @@ -3759,8 +3759,13 @@ private function readLabelSst(): void
3759
3759
} else {
3760
3760
$ textRun = $ richText ->createTextRun ($ text );
3761
3761
if (isset ($ fmtRuns [$ i - 1 ])) {
3762
- $ fontIndex = $ fmtRuns [$ i - 1 ]['fontIndex ' ];
3763
-
3762
+ if ($ fmtRuns [$ i - 1 ]['fontIndex ' ] < 4 ) {
3763
+ $ fontIndex = $ fmtRuns [$ i - 1 ]['fontIndex ' ];
3764
+ } else {
3765
+ // this has to do with that index 4 is omitted in all BIFF versions for some stra nge reason
3766
+ // check the OpenOffice documentation of the FONT record
3767
+ $ fontIndex = $ fmtRuns [$ i - 1 ]['fontIndex ' ] - 1 ;
3768
+ }
3764
3769
if (array_key_exists ($ fontIndex , $ this ->objFonts ) === false ) {
3765
3770
$ fontIndex = count ($ this ->objFonts ) - 1 ;
3766
3771
}
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace PhpOffice \PhpSpreadsheetTests \Reader \Xls ;
4
+
5
+ use PhpOffice \PhpSpreadsheet \Reader \Xls ;
6
+ use PhpOffice \PhpSpreadsheetTests \Functional \AbstractFunctional ;
7
+
8
+ class RichTextSizeTest extends AbstractFunctional
9
+ {
10
+ public function testRichTextRunSize (): void
11
+ {
12
+ $ filename = 'tests/data/Reader/XLS/RichTextFontSize.xls ' ;
13
+ $ reader = new Xls ();
14
+ $ spreadsheet = $ reader ->load ($ filename );
15
+ $ sheet = $ spreadsheet ->getSheetByName ('橱柜门板 ' );
16
+ self ::assertNotNull ($ sheet );
17
+ $ text = $ sheet ->getCell ('L15 ' )->getValue ();
18
+ $ elements = $ text ->getRichTextElements ();
19
+ self ::assertEquals (10 , $ elements [2 ]->getFont ()->getSize ());
20
+ $ spreadsheet ->disconnectWorksheets ();
21
+ }
22
+ }
You can’t perform that action at this time.
0 commit comments