From 61b2480cc1e34755855c9a6a08ee31dadabc9ef3 Mon Sep 17 00:00:00 2001 From: willkensonh Date: Fri, 12 Oct 2018 09:34:19 +1100 Subject: [PATCH] update colWidth function --- src/Spout/Writer/Common/Entity/Worksheet.php | 18 ++++-------------- src/Spout/Writer/WriterMultiSheetsAbstract.php | 16 ++++------------ 2 files changed, 8 insertions(+), 26 deletions(-) diff --git a/src/Spout/Writer/Common/Entity/Worksheet.php b/src/Spout/Writer/Common/Entity/Worksheet.php index e1c8aaa..d2c66a4 100644 --- a/src/Spout/Writer/Common/Entity/Worksheet.php +++ b/src/Spout/Writer/Common/Entity/Worksheet.php @@ -127,10 +127,10 @@ class Worksheet * @param float $width * @throws IOException */ - public function setColWidth(string $col, float $width) + public function setColWidth(int $colFrom, int $colTo, float $width) { $this->throwIfSheetFilePointerIsAlreadyCreated(); - $this->colWidths[$col] = $width; + $this->colWidths[] = [$colFrom,$colTo,$width]; } /** @@ -165,16 +165,6 @@ class Worksheet $this->merges[] = $leftCell . ':' . $rightCell; } - /** - * remove merged cell reference. - * @param string $leftCell - * @param string $rightCell - */ - public function unMergeCells(string $leftCell, string $rightCell) - { - $this->merges = array_diff($this->merges,[$leftCell . ':' . $rightCell]); - } - /** * used by WorksheetManager to get default row height and width xml to inject into worksheet xml file * @return string @@ -200,8 +190,8 @@ class Worksheet return ''; } $xml = ''; - foreach ($this->colWidths as $col => $width) { - $xml .= ''; //style and customWidth may be unnecessary ?? + foreach ($this->colWidths as $entry) { + $xml .= ''; //style and customWidth may be unnecessary ?? } $xml .= ''; return $xml; diff --git a/src/Spout/Writer/WriterMultiSheetsAbstract.php b/src/Spout/Writer/WriterMultiSheetsAbstract.php index 05e3ef6..9c007ca 100644 --- a/src/Spout/Writer/WriterMultiSheetsAbstract.php +++ b/src/Spout/Writer/WriterMultiSheetsAbstract.php @@ -187,13 +187,14 @@ abstract class WriterMultiSheetsAbstract extends WriterAbstract } /** - * @param string $col + * @param string $colFrom + * @param string $colTo * @param float $width * @throws \Box\Spout\Common\Exception\IOException */ - public function setColWidth(string $col, float $width) + public function setColWidth(int $colFrom, int $colTo, float $width) { - $this->workbookManager->getCurrentWorksheet()->setColWidth($col, $width); + $this->workbookManager->getCurrentWorksheet()->setColWidth($colFrom, $colTo, $width); } /** @@ -222,13 +223,4 @@ abstract class WriterMultiSheetsAbstract extends WriterAbstract { $this->workbookManager->getCurrentWorksheet()->mergeCells($leftCell,$rightCell); } - - /** - * @param string $leftCell - * @param string $rightCell - */ - public function unMergeCells(string $leftCell, string $rightCell) - { - $this->workbookManager->getCurrentWorksheet()->unMergeCells($leftCell,$rightCell); - } }