Sheet visibility - XLSX writer and reader
This commit is contained in:
1 parent
ddfa40e8b3
commit
b9206fcb4b
8 files changed
+102
-8
No files matched your search
@@ -53,6 +53,7 @@ class EntityFactory implements EntityFactoryInterface
|
||||
* @param int $sheetIndex Index of the sheet, based on order in the workbook (zero-based)
|
||||
* @param string $sheetName Name of the sheet
|
||||
* @param bool $isSheetActive Whether the sheet was defined as active
|
||||
* @param bool $isSheetVisible Whether the sheet is visible
|
||||
* @param \Box\Spout\Common\Manager\OptionsManagerInterface $optionsManager Reader's options manager
|
||||
* @param SharedStringsManager $sharedStringsManager Manages shared strings
|
||||
* @return Sheet
|
||||
@@ -63,12 +64,13 @@ class EntityFactory implements EntityFactoryInterface
|
||||
$sheetIndex,
|
||||
$sheetName,
|
||||
$isSheetActive,
|
||||
$isSheetVisible,
|
||||
$optionsManager,
|
||||
$sharedStringsManager
|
||||
) {
|
||||
$rowIterator = $this->createRowIterator($filePath, $sheetDataXMLFilePath, $optionsManager, $sharedStringsManager);
|
||||
|
||||
return new Sheet($rowIterator, $sheetIndex, $sheetName, $isSheetActive);
|
||||
return new Sheet($rowIterator, $sheetIndex, $sheetName, $isSheetActive, $isSheetVisible);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -29,9 +29,13 @@ class SheetManager
|
||||
const XML_ATTRIBUTE_ACTIVE_TAB = 'activeTab';
|
||||
const XML_ATTRIBUTE_R_ID = 'r:id';
|
||||
const XML_ATTRIBUTE_NAME = 'name';
|
||||
const XML_ATTRIBUTE_STATE = 'state';
|
||||
const XML_ATTRIBUTE_ID = 'Id';
|
||||
const XML_ATTRIBUTE_TARGET = 'Target';
|
||||
|
||||
/** State value to represent a hidden sheet */
|
||||
const SHEET_STATE_HIDDEN = 'hidden';
|
||||
|
||||
/** @var string Path of the XLSX file being read */
|
||||
protected $filePath;
|
||||
|
||||
@@ -163,6 +167,10 @@ class SheetManager
|
||||
protected function getSheetFromSheetXMLNode($xmlReaderOnSheetNode, $sheetIndexZeroBased, $isSheetActive)
|
||||
{
|
||||
$sheetId = $xmlReaderOnSheetNode->getAttribute(self::XML_ATTRIBUTE_R_ID);
|
||||
|
||||
$sheetState = $xmlReaderOnSheetNode->getAttribute(self::XML_ATTRIBUTE_STATE);
|
||||
$isSheetVisible = ($sheetState !== self::SHEET_STATE_HIDDEN);
|
||||
|
||||
$escapedSheetName = $xmlReaderOnSheetNode->getAttribute(self::XML_ATTRIBUTE_NAME);
|
||||
$sheetName = $this->escaper->unescape($escapedSheetName);
|
||||
|
||||
@@ -174,6 +182,7 @@ class SheetManager
|
||||
$sheetIndexZeroBased,
|
||||
$sheetName,
|
||||
$isSheetActive,
|
||||
$isSheetVisible,
|
||||
$this->optionsManager,
|
||||
$this->sharedStringsManager
|
||||
);
|
||||
|
||||
@@ -22,18 +22,23 @@ class Sheet implements SheetInterface
|
||||
/** @var bool Whether the sheet was the active one */
|
||||
protected $isActive;
|
||||
|
||||
/** @var bool Whether the sheet is visible */
|
||||
protected $isVisible;
|
||||
|
||||
/**
|
||||
* @param RowIterator $rowIterator The corresponding row iterator
|
||||
* @param int $sheetIndex Index of the sheet, based on order in the workbook (zero-based)
|
||||
* @param string $sheetName Name of the sheet
|
||||
* @param bool $isSheetActive Whether the sheet was defined as active
|
||||
* @param bool $isSheetVisible Whether the sheet is visible
|
||||
*/
|
||||
public function __construct($rowIterator, $sheetIndex, $sheetName, $isSheetActive)
|
||||
public function __construct($rowIterator, $sheetIndex, $sheetName, $isSheetActive, $isSheetVisible)
|
||||
{
|
||||
$this->rowIterator = $rowIterator;
|
||||
$this->index = $sheetIndex;
|
||||
$this->name = $sheetName;
|
||||
$this->isActive = $isSheetActive;
|
||||
$this->isVisible = $isSheetVisible;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -67,4 +72,12 @@ class Sheet implements SheetInterface
|
||||
{
|
||||
return $this->isActive;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool Whether the sheet is visible
|
||||
*/
|
||||
public function isVisible()
|
||||
{
|
||||
return $this->isVisible;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user