Пример #1
0
 /**
  * Processes the shared strings item XML node which the given XML reader is positioned on.
  *
  * @param \Box\Spout\Reader\Wrapper\XMLReader $xmlReader
  * @param int $sharedStringIndex Index of the processed shared strings item
  * @param \Box\Spout\Common\Escaper\XLSX $escaper Helper to escape values
  * @return void
  */
 protected function processSharedStringsItem($xmlReader, $sharedStringIndex, $escaper)
 {
     $node = $this->getSimpleXmlElementNodeFromXMLReader($xmlReader);
     $node->registerXPathNamespace('ns', self::MAIN_NAMESPACE_FOR_SHARED_STRINGS_XML);
     // removes nodes that should not be read, like the pronunciation of the Kanji characters
     $cleanNode = $this->removeSuperfluousTextNodes($node);
     // find all text nodes "t"; there can be multiple if the cell contains formatting
     $textNodes = $cleanNode->xpath('//ns:t');
     $textValue = $this->extractTextValueForNodes($textNodes);
     $unescapedTextValue = $escaper->unescape($textValue);
     $this->cachingStrategy->addStringForIndex($unescapedTextValue, $sharedStringIndex);
 }
Пример #2
0
 /**
  * Returns the cell String value, where string is stored in value node.
  *
  * @param string $nodeValue
  * @param \Box\Spout\Common\Escaper\XLSX $escaper
  * @return string The value associated with the cell (null when the cell has an error)
  */
 protected function formatStrCellValue($nodeValue, $escaper)
 {
     $escapedCellValue = trim($nodeValue);
     $cellValue = $escaper->unescape($escapedCellValue);
     return $cellValue;
 }