Sets the sheet visibility
This commit is contained in:
parent
d68a829e1f
commit
d32dd188d5
@ -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
|
||||
|
@ -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 .= '<sheet name="' . $escaper->escape($worksheetName) . '" sheetId="' . $worksheetId . '" r:id="rIdSheet' . $worksheetId . '"/>';
|
||||
$workbookXmlFileContents .= '<sheet name="' . $escaper->escape($worksheetName) . '" sheetId="' . $worksheetId . '" state="' . $worksheetState. '" r:id="rIdSheet' . $worksheetId . '"/>';
|
||||
}
|
||||
|
||||
$workbookXmlFileContents .= <<<EOD
|
||||
|
Loading…
x
Reference in New Issue
Block a user