Fix XLSX broken vertical align font style (#2619)
* Fix XLSX broken vertical align font style * Add fix information to changelog * Fix phpcs issues
This commit is contained in:
parent
579145eb3c
commit
0cb60a5098
|
|
@ -25,6 +25,8 @@ and this project adheres to [Semantic Versioning](https://semver.org).
|
|||
|
||||
### Fixed
|
||||
|
||||
- Fixed behaviour of XLSX font style vertical align settings
|
||||
|
||||
## 1.22.0 - 2022-02-18
|
||||
|
||||
### Added
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ class Styles extends BaseParserClass
|
|||
}
|
||||
if (isset($fontStyleXml->vertAlign)) {
|
||||
$attr = $this->getStyleAttributes($fontStyleXml->vertAlign);
|
||||
if (!isset($attr['val'])) {
|
||||
if (isset($attr['val'])) {
|
||||
$verticalAlign = strtolower((string) $attr['val']);
|
||||
if ($verticalAlign === 'superscript') {
|
||||
$fontStyle->setSuperscript(true);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheetTests\Reader\Xlsx;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class VerticalAlignTest extends TestCase
|
||||
{
|
||||
public function testVerticalAlignStyle(): void
|
||||
{
|
||||
$filename = 'tests/data/Reader/XLSX/verticalAlignTest.xlsx';
|
||||
$reader = IOFactory::createReader('Xlsx');
|
||||
$sheet = $reader->load($filename)->getActiveSheet();
|
||||
|
||||
self::assertTrue($sheet->getCell('A1')->getStyle()->getFont()->getSuperscript());
|
||||
self::assertFalse($sheet->getCell('A1')->getStyle()->getFont()->getSubscript());
|
||||
|
||||
self::assertTrue($sheet->getCell('B1')->getStyle()->getFont()->getSubscript());
|
||||
self::assertFalse($sheet->getCell('B1')->getStyle()->getFont()->getSuperscript());
|
||||
|
||||
self::assertFalse($sheet->getCell('C1')->getStyle()->getFont()->getSubscript());
|
||||
self::assertFalse($sheet->getCell('C1')->getStyle()->getFont()->getSuperscript());
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Loading…
Reference in New Issue