45 if (isset($fontStyleXml->name, $fontStyleXml->name[
'val'])) {
46 $fontStyle->
setName((
string) $fontStyleXml->name[
'val']);
48 if (isset($fontStyleXml->sz, $fontStyleXml->sz[
'val'])) {
49 $fontStyle->
setSize((
float) $fontStyleXml->sz[
'val']);
51 if (isset($fontStyleXml->b)) {
52 $fontStyle->
setBold(!isset($fontStyleXml->b[
'val']) || self::boolean((
string) $fontStyleXml->b[
'val']));
54 if (isset($fontStyleXml->i)) {
55 $fontStyle->
setItalic(!isset($fontStyleXml->i[
'val']) || self::boolean((
string) $fontStyleXml->i[
'val']));
57 if (isset($fontStyleXml->strike)) {
59 !isset($fontStyleXml->strike[
'val']) || self::boolean((
string) $fontStyleXml->strike[
'val'])
62 $fontStyle->
getColor()->setARGB(self::readColor($fontStyleXml->color));
64 if (isset($fontStyleXml->u) && !isset($fontStyleXml->u[
'val'])) {
66 } elseif (isset($fontStyleXml->u, $fontStyleXml->u[
'val'])) {
67 $fontStyle->
setUnderline((
string) $fontStyleXml->u[
'val']);
70 if (isset($fontStyleXml->vertAlign, $fontStyleXml->vertAlign[
'val'])) {
71 $verticalAlign = strtolower((
string) $fontStyleXml->vertAlign[
'val']);
72 if ($verticalAlign ===
'superscript') {
74 } elseif ($verticalAlign ===
'subscript') {
82 if ($numfmtStyleXml->count() === 0) {
85 $numfmt = $numfmtStyleXml->attributes();
86 if ($numfmt->count() > 0 && isset($numfmt[
'formatCode'])) {
93 if ($fillStyleXml->gradientFill) {
95 $gradientFill = $fillStyleXml->gradientFill[0];
96 if (!empty($gradientFill[
'type'])) {
97 $fillStyle->
setFillType((
string) $gradientFill[
'type']);
99 $fillStyle->
setRotation((
float) ($gradientFill[
'degree']));
100 $gradientFill->registerXPathNamespace(
'sml',
'http://schemas.openxmlformats.org/spreadsheetml/2006/main');
102 self::readColor(self::getArrayItem($gradientFill->xpath(
'sml:stop[@position=0]'))->
color)
105 self::readColor(self::getArrayItem($gradientFill->xpath(
'sml:stop[@position=1]'))->
color)
107 } elseif ($fillStyleXml->patternFill) {
109 if ($fillStyleXml->patternFill->fgColor) {
110 $fillStyle->
getStartColor()->setARGB(self::readColor($fillStyleXml->patternFill->fgColor,
true));
113 if ($fillStyleXml->patternFill->bgColor) {
114 $fillStyle->
getEndColor()->setARGB(self::readColor($fillStyleXml->patternFill->bgColor,
true));
118 $patternType = (string) $fillStyleXml->patternFill[
'patternType'] !=
'' 119 ? (
string) $fillStyleXml->patternFill[
'patternType']
128 $diagonalUp = self::boolean((
string) $borderStyleXml[
'diagonalUp']);
129 $diagonalDown = self::boolean((
string) $borderStyleXml[
'diagonalDown']);
130 if (!$diagonalUp && !$diagonalDown) {
132 } elseif ($diagonalUp && !$diagonalDown) {
134 } elseif (!$diagonalUp && $diagonalDown) {
140 self::readBorder($borderStyle->
getLeft(), $borderStyleXml->left);
141 self::readBorder($borderStyle->
getRight(), $borderStyleXml->right);
142 self::readBorder($borderStyle->
getTop(), $borderStyleXml->top);
143 self::readBorder($borderStyle->
getBottom(), $borderStyleXml->bottom);
144 self::readBorder($borderStyle->
getDiagonal(), $borderStyleXml->diagonal);
149 if (isset($borderXml[
'style'])) {
152 if (isset($borderXml->color)) {
153 $border->
getColor()->setARGB(self::readColor($borderXml->color));
159 $alignment->
setHorizontal((
string) $alignmentXml[
'horizontal']);
160 $alignment->
setVertical((
string) $alignmentXml[
'vertical']);
163 if ((
int) $alignmentXml[
'textRotation'] <= 90) {
164 $textRotation = (int) $alignmentXml[
'textRotation'];
165 } elseif ((
int) $alignmentXml[
'textRotation'] > 90) {
166 $textRotation = 90 - (int) $alignmentXml[
'textRotation'];
170 $alignment->
setWrapText(self::boolean((
string) $alignmentXml[
'wrapText']));
171 $alignment->
setShrinkToFit(self::boolean((
string) $alignmentXml[
'shrinkToFit']));
173 (
int) ((
string) $alignmentXml[
'indent']) > 0 ? (
int) ((
string) $alignmentXml[
'indent']) : 0
176 (
int) ((
string) $alignmentXml[
'readingOrder']) > 0 ? (
int) ((
string) $alignmentXml[
'readingOrder']) : 0
188 if (isset(
$style->font)) {
192 if (isset(
$style->fill)) {
196 if (isset(
$style->border)) {
200 if (isset(
$style->alignment->alignment)) {
205 if (isset(
$style->protection)) {
206 self::readProtectionLocked($docStyle,
$style);
207 self::readProtectionHidden($docStyle,
$style);
211 if (isset(
$style->quotePrefix)) {
218 if (isset(
$style->protection[
'locked'])) {
219 if (self::boolean((
string)
$style->protection[
'locked'])) {
229 if (isset(
$style->protection[
'hidden'])) {
230 if (self::boolean((
string)
$style->protection[
'hidden'])) {
238 public static function readColor($color, $background =
false)
240 if (isset($color[
'rgb'])) {
241 return (
string) $color[
'rgb'];
242 } elseif (isset($color[
'indexed'])) {
244 } elseif (isset($color[
'theme'])) {
245 if (self::$theme !== null) {
246 $returnColour = self::$theme->getColourByIndex((
int) $color[
'theme']);
247 if (isset($color[
'tint'])) {
248 $tintAdjust = (float) $color[
'tint'];
249 $returnColour = Color::changeBrightness($returnColour, $tintAdjust);
252 return 'FF' . $returnColour;
256 return ($background) ?
'FFFFFFFF' :
'FF000000';
264 if ($this->styleXml->dxfs) {
265 foreach ($this->styleXml->dxfs->dxf as $dxf) {
272 if ($this->styleXml->cellStyles) {
273 foreach ($this->styleXml->cellStyles->cellStyle as $cellStyle) {
274 if ((
int) ($cellStyle[
'builtinId']) == 0) {
275 if (isset($this->cellStyles[(
int) ($cellStyle[
'xfId'])])) {
278 $this->
readStyle(
$style, $this->cellStyles[(
int) ($cellStyle[
'xfId'])]);
297 return $array[
$key] ?? null;
getColor()
Get Border Color.
setItalic($pValue)
Set Italic.
static readProtectionHidden(Style $docStyle, $style)
setFillType($pValue)
Set Fill Type.
setSubscript(bool $pValue)
Set Subscript.
setIndent($pValue)
Set indent.
if(PHP_SAPI !='cli') color
setRotation($pValue)
Set Rotation.
setSize($sizeInPoints)
Set Size.
getStartColor()
Get Start Color.
setQuotePrefix($pValue)
Set quote prefix.
static readFontStyle(Font $fontStyle, SimpleXMLElement $fontStyleXml)
static readBorderStyle(Borders $borderStyle, SimpleXMLElement $borderStyleXml)
getDiagonal()
Get Diagonal.
static indexedColor($pIndex, $background=false)
Get indexed color.
setTextRotation($pValue)
Set TextRotation.
static readNumberFormat(NumberFormat $numfmtStyle, SimpleXMLElement $numfmtStyleXml)
const PROTECTION_PROTECTED
static readProtectionLocked(Style $docStyle, $style)
setWrapText($pValue)
Set Wrap Text.
readStyle(Style $docStyle, $style)
setBorderStyle($pValue)
Set Border style.
static readColor($color, $background=false)
dxfs($readDataOnly=false)
setSuperscript(bool $pValue)
Set Superscript.
setShrinkToFit($pValue)
Set Shrink to fit.
setUnderline($pValue)
Set Underline.
setStyleBaseData(?Theme $theme=null, $styles=[], $cellStyles=[])
getProtection()
Get Protection.
getAlignment()
Get Alignment.
getNumberFormat()
Get Number Format.
setDiagonalDirection($pValue)
Set DiagonalDirection.
const PROTECTION_UNPROTECTED
setStrikethrough($pValue)
Set Strikethrough.
setReadOrder($pValue)
Set read order.
setName($fontname)
Set Name.
static readAlignmentStyle(Alignment $alignment, SimpleXMLElement $alignmentXml)
__construct(SimpleXMLElement $styleXml)
static getArrayItem($array, $key=0)
static readBorder(Border $border, SimpleXMLElement $borderXml)
setVertical($pValue)
Set Vertical.
setBold($pValue)
Set Bold.
getEndColor()
Get End Color.
setHorizontal($pValue)
Set Horizontal.