Skip to content

Commit 3803658

Browse files
author
MarkBaker
committed
Some basic reading of font style information for CF Styles
1 parent 3767917 commit 3803658

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/PhpSpreadsheet/Reader/Xls.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use PhpOffice\PhpSpreadsheet\Cell\DataValidation;
88
use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException;
99
use PhpOffice\PhpSpreadsheet\NamedRange;
10+
use PhpOffice\PhpSpreadsheet\Reader\Xls\Color;
1011
use PhpOffice\PhpSpreadsheet\Reader\Xls\ConditionalFormatting;
1112
use PhpOffice\PhpSpreadsheet\Reader\Xls\Style\CellFont;
1213
use PhpOffice\PhpSpreadsheet\RichText\RichText;
@@ -8071,6 +8072,21 @@ private function getCFStyleOptions(int $options, Style $style): void
80718072

80728073
private function getCFFontStyle(string $options, Style $style): void
80738074
{
8075+
$fontSize = self::getInt4d($options, 64);
8076+
$fontSize = ($fontSize !== -1) ? $fontSize / 20 : -1;
8077+
$bold = self::getUInt2d($options, 72) === 700; // 400 = normal, 700 = bold
8078+
$color = self::getInt4d($options, 80);
8079+
8080+
if ($fontSize !== -1) {
8081+
$style->getFont()->setSize($fontSize);
8082+
}
8083+
if ($color !== -1) {
8084+
$style->getFont()->setColor(
8085+
new \PhpOffice\PhpSpreadsheet\Style\Color(Color::map($color, $this->palette, $this->version)['rgb'])
8086+
);
8087+
}
8088+
$style->getFont()
8089+
->setBold($bold);
80748090
}
80758091

80768092
private function getCFAlignmentStyle(string $options, Style $style): void

0 commit comments

Comments
 (0)