See Release Notes
Long Term Support Release
1 <?php 2 3 namespace Box\Spout\Reader\ODS\Helper; 4 5 use Box\Spout\Reader\Exception\XMLProcessingException; 6 use Box\Spout\Reader\ODS\Creator\InternalEntityFactory; 7 8 /** 9 * Class SettingsHelper 10 * This class provides helper functions to extract data from the "settings.xml" file. 11 */ 12 class SettingsHelper 13 { 14 const SETTINGS_XML_FILE_PATH = 'settings.xml'; 15 16 /** Definition of XML nodes name and attribute used to parse settings data */ 17 const XML_NODE_CONFIG_ITEM = 'config:config-item'; 18 const XML_ATTRIBUTE_CONFIG_NAME = 'config:name'; 19 const XML_ATTRIBUTE_VALUE_ACTIVE_TABLE = 'ActiveTable'; 20 21 /** @var InternalEntityFactory Factory to create entities */ 22 private $entityFactory; 23 24 /** 25 * @param InternalEntityFactory $entityFactory Factory to create entities 26 */ 27 public function __construct($entityFactory) 28 { 29 $this->entityFactory = $entityFactory; 30 } 31 32 /** 33 * @param string $filePath Path of the file to be read 34 * @return string|null Name of the sheet that was defined as active or NULL if none found 35 */ 36 public function getActiveSheetName($filePath) 37 { 38 $xmlReader = $this->entityFactory->createXMLReader(); 39 if ($xmlReader->openFileInZip($filePath, self::SETTINGS_XML_FILE_PATH) === false) { 40 return null; 41 } 42 43 $activeSheetName = null; 44 45 try { 46 while ($xmlReader->readUntilNodeFound(self::XML_NODE_CONFIG_ITEM)) { 47 if ($xmlReader->getAttribute(self::XML_ATTRIBUTE_CONFIG_NAME) === self::XML_ATTRIBUTE_VALUE_ACTIVE_TABLE) { 48 $activeSheetName = $xmlReader->readString(); 49 break; 50 } 51 } 52 } catch (XMLProcessingException $exception) { 53 // do nothing 54 } 55 56 $xmlReader->close(); 57 58 return $activeSheetName; 59 } 60 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body