init
This commit is contained in:
commit
72a26edcff
22092 changed files with 2101903 additions and 0 deletions
58
lib/PhpSpreadsheet/Reader/Xml/Style/Alignment.php
Normal file
58
lib/PhpSpreadsheet/Reader/Xml/Style/Alignment.php
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheet\Reader\Xml\Style;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Style\Alignment as AlignmentStyles;
|
||||
use SimpleXMLElement;
|
||||
|
||||
class Alignment extends StyleBase
|
||||
{
|
||||
protected const VERTICAL_ALIGNMENT_STYLES = [
|
||||
AlignmentStyles::VERTICAL_BOTTOM,
|
||||
AlignmentStyles::VERTICAL_TOP,
|
||||
AlignmentStyles::VERTICAL_CENTER,
|
||||
AlignmentStyles::VERTICAL_JUSTIFY,
|
||||
];
|
||||
|
||||
protected const HORIZONTAL_ALIGNMENT_STYLES = [
|
||||
AlignmentStyles::HORIZONTAL_GENERAL,
|
||||
AlignmentStyles::HORIZONTAL_LEFT,
|
||||
AlignmentStyles::HORIZONTAL_RIGHT,
|
||||
AlignmentStyles::HORIZONTAL_CENTER,
|
||||
AlignmentStyles::HORIZONTAL_CENTER_CONTINUOUS,
|
||||
AlignmentStyles::HORIZONTAL_JUSTIFY,
|
||||
];
|
||||
|
||||
public function parseStyle(SimpleXMLElement $styleAttributes): array
|
||||
{
|
||||
$style = [];
|
||||
|
||||
foreach ($styleAttributes as $styleAttributeKey => $styleAttributeValue) {
|
||||
$styleAttributeValue = (string) $styleAttributeValue;
|
||||
switch ($styleAttributeKey) {
|
||||
case 'Vertical':
|
||||
if (self::identifyFixedStyleValue(self::VERTICAL_ALIGNMENT_STYLES, $styleAttributeValue)) {
|
||||
$style['alignment']['vertical'] = $styleAttributeValue;
|
||||
}
|
||||
|
||||
break;
|
||||
case 'Horizontal':
|
||||
if (self::identifyFixedStyleValue(self::HORIZONTAL_ALIGNMENT_STYLES, $styleAttributeValue)) {
|
||||
$style['alignment']['horizontal'] = $styleAttributeValue;
|
||||
}
|
||||
|
||||
break;
|
||||
case 'WrapText':
|
||||
$style['alignment']['wrapText'] = true;
|
||||
|
||||
break;
|
||||
case 'Rotate':
|
||||
$style['alignment']['textRotation'] = $styleAttributeValue;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $style;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue