From 0c87ff1a7b5ca14beca397ecd9f2b504ac627942 Mon Sep 17 00:00:00 2001 From: Jephte Clain Date: Fri, 29 Nov 2024 19:39:14 +0400 Subject: [PATCH] =?UTF-8?q?am=C3=A9liorer=20gestion=20bordures?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/spout/SpoutBuilder.php | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/src/spout/SpoutBuilder.php b/src/spout/SpoutBuilder.php index dd7887a..4d64bba 100644 --- a/src/spout/SpoutBuilder.php +++ b/src/spout/SpoutBuilder.php @@ -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;