Beispiel #1
0
 /**
  * Reads the styles.xml file and extract the relevant information from the file.
  *
  * @return void
  */
 protected function extractRelevantInfo()
 {
     $this->customNumberFormats = [];
     $this->stylesAttributes = [];
     $xmlReader = new XMLReader();
     if ($xmlReader->openFileInZip($this->filePath, self::STYLES_XML_FILE_PATH)) {
         while ($xmlReader->read()) {
             if ($xmlReader->isPositionedOnStartingNode(self::XML_NODE_NUM_FMTS)) {
                 $numFmtsNode = new SimpleXMLElement($xmlReader->readOuterXml());
                 $this->extractNumberFormats($numFmtsNode);
             } else {
                 if ($xmlReader->isPositionedOnStartingNode(self::XML_NODE_CELL_XFS)) {
                     $cellXfsNode = new SimpleXMLElement($xmlReader->readOuterXml());
                     $this->extractStyleAttributes($cellXfsNode);
                 }
             }
         }
         $xmlReader->close();
     }
 }
Beispiel #2
0
 /**
  * Returns a SimpleXMLElement node from the current node in the given XMLReader instance.
  * This is to simplify the parsing of the subtree.
  *
  * @param \Box\Spout\Reader\Wrapper\XMLReader $xmlReader
  * @return \Box\Spout\Reader\Wrapper\SimpleXMLElement
  * @throws \Box\Spout\Common\Exception\IOException If the current node cannot be read
  */
 protected function getSimpleXmlElementNodeFromXMLReader($xmlReader)
 {
     $node = null;
     try {
         $node = new SimpleXMLElement($xmlReader->readOuterXml());
     } catch (XMLProcessingException $exception) {
         throw new IOException("The sharedStrings.xml file contains unreadable data [{$exception->getMessage()}].");
     }
     return $node;
 }