From d32dd188d516192225d0eb1ddc74cc87a489c5bf Mon Sep 17 00:00:00 2001 From: alexisparron Date: Tue, 4 Jul 2017 16:07:48 +0200 Subject: [PATCH] Sets the sheet visibility --- src/Spout/Writer/Common/Sheet.php | 21 +++++++++++++++++++ .../Writer/XLSX/Helper/FileSystemHelper.php | 4 +++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/Spout/Writer/Common/Sheet.php b/src/Spout/Writer/Common/Sheet.php index 0d8c63b..508d037 100644 --- a/src/Spout/Writer/Common/Sheet.php +++ b/src/Spout/Writer/Common/Sheet.php @@ -33,6 +33,9 @@ class Sheet /** @var string Name of the sheet */ protected $name; + /** @var bool isVisible visibility of the sheet */ + protected $isVisible; + /** @var \Box\Spout\Common\Helper\StringHelper */ protected $stringHelper; @@ -50,6 +53,7 @@ class Sheet $this->stringHelper = new StringHelper(); $this->setName(self::DEFAULT_SHEET_NAME_PREFIX . ($sheetIndex + 1)); + $this->setVisibility(); } /** @@ -70,6 +74,23 @@ class Sheet return $this->name; } + /** + * @api + * @return bool isVisible visibility of the sheet + */ + public function isVisible() + { + return $this->isVisible; + } + + public function setVisibility($visibility = true) + { + $this->isVisible = $visibility; + + return $this; + } + + /** * Sets the name of the sheet. Note that Excel has some restrictions on the name: * - it should not be blank diff --git a/src/Spout/Writer/XLSX/Helper/FileSystemHelper.php b/src/Spout/Writer/XLSX/Helper/FileSystemHelper.php index 86515f3..7238dcc 100644 --- a/src/Spout/Writer/XLSX/Helper/FileSystemHelper.php +++ b/src/Spout/Writer/XLSX/Helper/FileSystemHelper.php @@ -289,8 +289,10 @@ EOD; /** @var Worksheet $worksheet */ foreach ($worksheets as $worksheet) { $worksheetName = $worksheet->getExternalSheet()->getName(); + $worksheetState = ( $worksheet->getExternalSheet()->isVisible() ) ? 'visible' : 'hidden'; + $worksheetId = $worksheet->getId(); - $workbookXmlFileContents .= ''; + $workbookXmlFileContents .= ''; } $workbookXmlFileContents .= <<