support de multiples définitions pour border
This commit is contained in:
parent
8d7512e2bf
commit
3cdcf4958d
@ -86,20 +86,23 @@ class SpoutBuilder extends AbstractBuilder {
|
||||
if (($wrap = $cell["wrap"] ?? null) !== null) $style->setShouldWrapText($wrap);
|
||||
if (($format = $cell["format"] ?? null) !== null) $style->setFormat($format);
|
||||
if (($border = $cell["border"] ?? null) !== null) {
|
||||
if (is_string($border)) {
|
||||
$parts = explode(" ", $border);
|
||||
$border = [];
|
||||
if (is_array($border)) $borderDefs = $border;
|
||||
else $borderDefs = preg_split('/\s*,\s*/', trim(strval($border)));
|
||||
$border = null;
|
||||
foreach ($borderDefs as $borderDef) {
|
||||
$parts = preg_split('/\s+/', $borderDef);
|
||||
$borderDef = [];
|
||||
$styleAll = null;
|
||||
$widthAll = null;
|
||||
$colorAll = null;
|
||||
foreach ($parts as $part) {
|
||||
if ($part === "all") {
|
||||
$border["left"] = [];
|
||||
$border["top"] = [];
|
||||
$border["right"] = [];
|
||||
$border["bottom"] = [];
|
||||
$borderDef["left"] = [];
|
||||
$borderDef["top"] = [];
|
||||
$borderDef["right"] = [];
|
||||
$borderDef["bottom"] = [];
|
||||
} elseif (preg_match('/^(left|top|right|bottom)$/', $part)) {
|
||||
$border[$part] = [];
|
||||
$borderDef[$part] = [];
|
||||
} elseif (preg_match('/^(none|solid|dashed|dotted|double)$/', $part)) {
|
||||
$styleAll = $part;
|
||||
} elseif (preg_match('/^(thin|medium|thick)$/', $part)) {
|
||||
@ -108,22 +111,22 @@ class SpoutBuilder extends AbstractBuilder {
|
||||
$colorAll = $part;
|
||||
}
|
||||
}
|
||||
foreach ($border as &$part) {
|
||||
foreach ($borderDef as &$part) {
|
||||
if ($styleAll !== null) $part["style"] = $styleAll;
|
||||
if ($widthAll !== null) $part["width"] = $widthAll;
|
||||
if ($colorAll !== null) $part["color"] = $colorAll;
|
||||
}; unset($part);
|
||||
}
|
||||
|
||||
$top = $border["top"] ?? null;
|
||||
$right = $border["right"] ?? null;
|
||||
$bottom = $border["bottom"] ?? null;
|
||||
$left = $border["left"] ?? null;
|
||||
$border = null;
|
||||
self::add_border_part($border, "top", $top);
|
||||
self::add_border_part($border, "right", $right);
|
||||
self::add_border_part($border, "bottom", $bottom);
|
||||
self::add_border_part($border, "left", $left);
|
||||
$top = $borderDef["top"] ?? null;
|
||||
$right = $borderDef["right"] ?? null;
|
||||
$bottom = $borderDef["bottom"] ?? null;
|
||||
$left = $borderDef["left"] ?? null;
|
||||
|
||||
self::add_border_part($border, "top", $top);
|
||||
self::add_border_part($border, "right", $right);
|
||||
self::add_border_part($border, "bottom", $bottom);
|
||||
self::add_border_part($border, "left", $left);
|
||||
}
|
||||
if ($border !== null) $style->setBorder($border);
|
||||
}
|
||||
return $style;
|
||||
|
Loading…
x
Reference in New Issue
Block a user