Fix font index problem (#2642)
* Fix font index problem * Update RichTextSizeTest.php Eliminate Phpstan failure. * Update RichTextSizeTest.php Eliminate now-unused import.
This commit is contained in:
parent
9caa827f41
commit
d593617287
|
|
@ -3759,8 +3759,13 @@ class Xls extends BaseReader
|
||||||
} else {
|
} else {
|
||||||
$textRun = $richText->createTextRun($text);
|
$textRun = $richText->createTextRun($text);
|
||||||
if (isset($fmtRuns[$i - 1])) {
|
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) {
|
if (array_key_exists($fontIndex, $this->objFonts) === false) {
|
||||||
$fontIndex = count($this->objFonts) - 1;
|
$fontIndex = count($this->objFonts) - 1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace PhpOffice\PhpSpreadsheetTests\Reader\Xls;
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Reader\Xls;
|
||||||
|
use PhpOffice\PhpSpreadsheetTests\Functional\AbstractFunctional;
|
||||||
|
|
||||||
|
class RichTextSizeTest extends AbstractFunctional
|
||||||
|
{
|
||||||
|
public function testRichTextRunSize(): void
|
||||||
|
{
|
||||||
|
$filename = 'tests/data/Reader/XLS/RichTextFontSize.xls';
|
||||||
|
$reader = new Xls();
|
||||||
|
$spreadsheet = $reader->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();
|
||||||
|
}
|
||||||
|
}
|
||||||
Binary file not shown.
Loading…
Reference in New Issue