75 '1' => Font::UNDERLINE_SINGLE,
76 '2' => Font::UNDERLINE_DOUBLE,
77 '3' => Font::UNDERLINE_SINGLEACCOUNTING,
78 '4' => Font::UNDERLINE_DOUBLEACCOUNTING,
96 if ($sheet->Styles->StyleRegion !== null) {
97 $this->
readStyles($sheet->Styles->StyleRegion, $maxRow, $maxCol);
103 foreach ($styleRegion as
$style) {
104 if ($style === null) {
108 $styleAttributes = $style->attributes();
109 if ($styleAttributes !== null && ($styleAttributes[
'startRow'] <= $maxRow) && ($styleAttributes[
'startCol'] <= $maxCol)) {
110 $cellRange = $this->
readStyleRange($styleAttributes, $maxCol, $maxRow);
112 $styleAttributes = $style->Style->attributes();
117 $formatCode = (string) $styleAttributes[
'Format'];
119 $styleArray[
'numberFormat'][
'formatCode'] = $formatCode;
121 if ($this->readDataOnly ===
false && $styleAttributes !== null) {
123 $styleArray[
'numberFormat'][
'formatCode'] = $formatCode;
124 $styleArray = $this->
readStyle($styleArray, $styleAttributes, $style);
126 $this->spreadsheet->getActiveSheet()->getStyle($cellRange)->applyFromArray($styleArray);
133 if (isset($srssb->Diagonal, $srssb->{
'Rev-Diagonal'})) {
134 $styleArray[
'borders'][
'diagonal'] = self::parseBorderAttributes($srssb->Diagonal->attributes());
136 } elseif (isset($srssb->Diagonal)) {
137 $styleArray[
'borders'][
'diagonal'] = self::parseBorderAttributes($srssb->Diagonal->attributes());
139 } elseif (isset($srssb->{
'Rev-Diagonal'})) {
140 $styleArray[
'borders'][
'diagonal'] = self::parseBorderAttributes($srssb->{
'Rev-Diagonal'}->attributes());
147 $ucDirection = ucfirst($direction);
148 if (isset($srssb->$ucDirection)) {
149 $styleArray[
'borders'][$direction] = self::parseBorderAttributes($srssb->$ucDirection->attributes());
155 $rotation = (int) $styleAttributes->Rotation;
156 if ($rotation >= 270 && $rotation <= 360) {
159 $rotation = (abs($rotation) > 90) ? 0 : $rotation;
164 private static function addStyle(array &$styleArray,
string $key,
string $value): void
166 if (array_key_exists($value, self::$mappings[$key])) {
167 $styleArray[
$key] = self::$mappings[
$key][$value];
171 private static function addStyle2(array &$styleArray,
string $key1,
string $key,
string $value): void
173 if (array_key_exists($value, self::$mappings[$key])) {
174 $styleArray[$key1][
$key] = self::$mappings[
$key][$value];
181 if ($borderAttributes !== null) {
182 if (isset($borderAttributes[
'Color'])) {
183 $styleArray[
'color'][
'rgb'] = self::parseGnumericColour($borderAttributes[
'Color']);
186 self::addStyle($styleArray,
'borderStyle', $borderAttributes[
'Style']);
194 [$gnmR, $gnmG, $gnmB] = explode(
':', $gnmColour);
195 $gnmR = substr(str_pad($gnmR, 4,
'0', STR_PAD_RIGHT), 0, 2);
196 $gnmG = substr(str_pad($gnmG, 4,
'0', STR_PAD_RIGHT), 0, 2);
197 $gnmB = substr(str_pad($gnmB, 4,
'0', STR_PAD_RIGHT), 0, 2);
199 return $gnmR . $gnmG . $gnmB;
204 $RGB = self::parseGnumericColour($styleAttributes[
'Fore']);
205 $styleArray[
'font'][
'color'][
'rgb'] = $RGB;
206 $RGB = self::parseGnumericColour($styleAttributes[
'Back']);
207 $shade = (string) $styleAttributes[
'Shade'];
208 if (($RGB !==
'000000') || ($shade !==
'0')) {
209 $RGB2 = self::parseGnumericColour($styleAttributes[
'PatternColor']);
210 if ($shade ===
'1') {
211 $styleArray[
'fill'][
'startColor'][
'rgb'] = $RGB;
212 $styleArray[
'fill'][
'endColor'][
'rgb'] = $RGB2;
214 $styleArray[
'fill'][
'endColor'][
'rgb'] = $RGB;
215 $styleArray[
'fill'][
'startColor'][
'rgb'] = $RGB2;
217 self::addStyle2($styleArray,
'fill',
'fillType', $shade);
224 $startRow = $styleAttributes[
'startRow'] + 1;
226 $endColumn = ($styleAttributes[
'endCol'] > $maxCol) ? $maxCol : (
int) $styleAttributes[
'endCol'];
229 $endRow = 1 + (($styleAttributes[
'endRow'] > $maxRow) ? $maxRow : (
int) $styleAttributes[
'endRow']);
230 $cellRange = $startColumn . $startRow .
':' . $endColumn . $endRow;
237 self::addStyle2($styleArray,
'alignment',
'horizontal', $styleAttributes[
'HAlign']);
238 self::addStyle2($styleArray,
'alignment',
'vertical', $styleAttributes[
'VAlign']);
239 $styleArray[
'alignment'][
'wrapText'] = $styleAttributes[
'WrapText'] ==
'1';
240 $styleArray[
'alignment'][
'textRotation'] = $this->
calcRotation($styleAttributes);
241 $styleArray[
'alignment'][
'shrinkToFit'] = $styleAttributes[
'ShrinkToFit'] ==
'1';
242 $styleArray[
'alignment'][
'indent'] = ((int) ($styleAttributes[
'Indent']) > 0) ? $styleAttributes[
'indent'] : 0;
244 $this->
addColors($styleArray, $styleAttributes);
246 $fontAttributes = $style->Style->Font->attributes();
247 if ($fontAttributes !== null) {
248 $styleArray[
'font'][
'name'] = (string) $style->Style->Font;
249 $styleArray[
'font'][
'size'] = (
int) ($fontAttributes[
'Unit']);
250 $styleArray[
'font'][
'bold'] = $fontAttributes[
'Bold'] ==
'1';
251 $styleArray[
'font'][
'italic'] = $fontAttributes[
'Italic'] ==
'1';
252 $styleArray[
'font'][
'strikethrough'] = $fontAttributes[
'StrikeThrough'] ==
'1';
253 self::addStyle2($styleArray,
'font',
'underline', $fontAttributes[
'Underline']);
255 switch ($fontAttributes[
'Script']) {
257 $styleArray[
'font'][
'superscript'] =
true;
261 $styleArray[
'font'][
'subscript'] =
true;
267 if (isset($style->Style->StyleBorder)) {
268 $srssb = $style->Style->StyleBorder;
275 if (isset($style->Style->HyperLink)) {
277 $hyperlink = $style->Style->HyperLink->attributes();
const FILL_PATTERN_GRAY125
addBorderStyle(SimpleXMLElement $srssb, array &$styleArray, string $direction)
const FILL_PATTERN_LIGHTTRELLIS
static parseGnumericColour(string $gnmColour)
const FILL_PATTERN_MEDIUMGRAY
const FILL_PATTERN_DARKUP
const HORIZONTAL_CENTER_CONTINUOUS
static __construct(Spreadsheet $spreadsheet, bool $readDataOnly)
static isDateTimeFormatCode($pFormatCode)
Is a given number format code a date/time?
const FILL_PATTERN_LIGHTVERTICAL
read(SimpleXMLElement $sheet, int $maxRow, int $maxCol)
const FILL_PATTERN_LIGHTDOWN
const BORDER_MEDIUMDASHED
const FILL_PATTERN_DARKGRAY
const FILL_PATTERN_DARKVERTICAL
addColors(array &$styleArray, SimpleXMLElement $styleAttributes)
if(!file_exists(getcwd() . '/ilias.ini.php'))
registration confirmation script for ilias
const FILL_PATTERN_LIGHTGRID
const FILL_PATTERN_DARKTRELLIS
readStyles(SimpleXMLElement $styleRegion, int $maxRow, int $maxCol)
readStyle(array $styleArray, SimpleXMLElement $styleAttributes, SimpleXMLElement $style)
static parseBorderAttributes(?SimpleXMLElement $borderAttributes)
calcRotation(SimpleXMLElement $styleAttributes)
const BORDER_SLANTDASHDOT
readStyleRange(SimpleXMLElement $styleAttributes, int $maxCol, int $maxRow)
const BORDER_MEDIUMDASHDOTDOT
addBorderDiagonal(SimpleXMLElement $srssb, array &$styleArray)
const FILL_PATTERN_GRAY0625
const FILL_PATTERN_DARKGRID
static stringFromColumnIndex($columnIndex)
String from column index.
const FILL_PATTERN_DARKHORIZONTAL
static addStyle(array &$styleArray, string $key, string $value)
const FILL_PATTERN_LIGHTGRAY
const FILL_PATTERN_DARKDOWN
static addStyle2(array &$styleArray, string $key1, string $key, string $value)
const FILL_PATTERN_LIGHTHORIZONTAL
const BORDER_MEDIUMDASHDOT
const FILL_PATTERN_LIGHTUP