From 99816b0b8ef958d232956e17ec766ce84a536bc1 Mon Sep 17 00:00:00 2001 From: Adrien Loison Date: Mon, 22 May 2017 14:39:26 +0200 Subject: [PATCH] Use openFileInZip() only (#421) --- .../Reader/XLSX/Helper/SharedStringsHelper.php | 13 +------------ src/Spout/Reader/XLSX/RowIterator.php | 3 +-- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/src/Spout/Reader/XLSX/Helper/SharedStringsHelper.php b/src/Spout/Reader/XLSX/Helper/SharedStringsHelper.php index 0e88839..415d5cf 100644 --- a/src/Spout/Reader/XLSX/Helper/SharedStringsHelper.php +++ b/src/Spout/Reader/XLSX/Helper/SharedStringsHelper.php @@ -80,8 +80,6 @@ class SharedStringsHelper * * The XML file can be really big with sheets containing a lot of data. That is why * we need to use a XML reader that provides streaming like the XMLReader library. - * Please note that SimpleXML does not provide such a functionality but since it is faster - * and more handy to parse few XML nodes, it is used in combination with XMLReader for that purpose. * * @return void * @throws \Box\Spout\Common\Exception\IOException If sharedStrings.xml can't be read @@ -91,8 +89,7 @@ class SharedStringsHelper $xmlReader = new XMLReader(); $sharedStringIndex = 0; - $sharedStringsFilePath = $this->getSharedStringsFilePath(); - if ($xmlReader->open($sharedStringsFilePath) === false) { + if ($xmlReader->openFileInZip($this->filePath, self::SHARED_STRINGS_XML_FILE_PATH) === false) { throw new IOException('Could not open "' . self::SHARED_STRINGS_XML_FILE_PATH . '".'); } @@ -119,14 +116,6 @@ class SharedStringsHelper $xmlReader->close(); } - /** - * @return string The path to the shared strings XML file - */ - protected function getSharedStringsFilePath() - { - return 'zip://' . $this->filePath . '#' . self::SHARED_STRINGS_XML_FILE_PATH; - } - /** * Returns the shared strings unique count, as specified in tag. * diff --git a/src/Spout/Reader/XLSX/RowIterator.php b/src/Spout/Reader/XLSX/RowIterator.php index 2440593..45069b3 100644 --- a/src/Spout/Reader/XLSX/RowIterator.php +++ b/src/Spout/Reader/XLSX/RowIterator.php @@ -128,8 +128,7 @@ class RowIterator implements IteratorInterface { $this->xmlReader->close(); - $sheetDataFilePath = 'zip://' . $this->filePath . '#' . $this->sheetDataXMLFilePath; - if ($this->xmlReader->open($sheetDataFilePath) === false) { + if ($this->xmlReader->openFileInZip($this->filePath, $this->sheetDataXMLFilePath) === false) { throw new IOException("Could not open \"{$this->sheetDataXMLFilePath}\"."); }