améliorer gestion bordures
This commit is contained in:
parent
8b79df5a75
commit
0c87ff1a7b
@ -108,9 +108,33 @@ class SpoutBuilder extends AbstractBuilder {
|
||||
if ($cell["wrap_text"] ?? null) $style->setShouldWrapText();
|
||||
if (($format = $cell["format"] ?? null) !== null) $style->setFormat($format);
|
||||
if (($border = $cell["border"] ?? null) !== null) {
|
||||
if ($border === "all") $params = "left top right bottom";
|
||||
if (is_string($border)) {
|
||||
$border = array_fill_keys(explode(" ", $border), []);
|
||||
$parts = explode(" ", $border);
|
||||
$border = [];
|
||||
$styleAll = null;
|
||||
$widthAll = null;
|
||||
$colorAll = null;
|
||||
foreach ($parts as $part) {
|
||||
if ($part === "all") {
|
||||
$border["left"] = [];
|
||||
$border["top"] = [];
|
||||
$border["right"] = [];
|
||||
$border["bottom"] = [];
|
||||
} elseif (preg_match('/^(left|top|right|bottom)$/', $part)) {
|
||||
$border[$part] = [];
|
||||
} elseif (preg_match('/^(none|solid|dashed|dotted|double)$/', $part)) {
|
||||
$styleAll = $part;
|
||||
} elseif (preg_match('/^(thin|medium|thick)$/', $part)) {
|
||||
$widthAll = $part;
|
||||
} else {
|
||||
$colorAll = $part;
|
||||
}
|
||||
}
|
||||
foreach ($border 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;
|
||||
|
Loading…
Reference in New Issue
Block a user