* fix #1114 issues

* fixed code style

* update for all version

* add test for bag 1114

* remove comment

Co-authored-by: georgio <georgiokot@gmail.cim>
This commit is contained in:
Georgiy 2021-10-03 19:29:23 +03:00 committed by GitHub
parent 90b9decb8e
commit fea0e34e90
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 6 deletions

View File

@ -3749,12 +3749,10 @@ class Xls extends BaseReader
} else { } else {
$textRun = $richText->createTextRun($text); $textRun = $richText->createTextRun($text);
if (isset($fmtRuns[$i - 1])) { if (isset($fmtRuns[$i - 1])) {
if ($fmtRuns[$i - 1]['fontIndex'] < 4) { $fontIndex = $fmtRuns[$i - 1]['fontIndex'];
$fontIndex = $fmtRuns[$i - 1]['fontIndex'];
} else { if (array_key_exists($fontIndex, $this->objFonts) === false) {
// this has to do with that index 4 is omitted in all BIFF versions for some strange reason $fontIndex = count($this->objFonts) - 1;
// check the OpenOffice documentation of the FONT record
$fontIndex = $fmtRuns[$i - 1]['fontIndex'] - 1;
} }
$textRun->setFont(clone $this->objFonts[$fontIndex]); $textRun->setFont(clone $this->objFonts[$fontIndex]);
} }

View File

@ -121,4 +121,13 @@ class XlsTest extends AbstractFunctional
self::assertSame('Ładowność', $sheet->getCell('I1')->getValue()); self::assertSame('Ładowność', $sheet->getCell('I1')->getValue());
$spreadsheet->disconnectWorksheets(); $spreadsheet->disconnectWorksheets();
} }
public function testLoadXlsBug1114(): void
{
$filename = 'tests/data/Reader/XLS/bug1114.xls';
$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($filename);
$sheet = $spreadsheet->getActiveSheet();
self::assertSame(1148140800.0, $sheet->getCell('B2')->getValue());
$spreadsheet->disconnectWorksheets();
}
} }

Binary file not shown.