Use openFileInZip() only (#421)

This commit is contained in:
Adrien Loison 2017-05-22 14:39:26 +02:00 committed by GitHub
parent 606103f7fc
commit 99816b0b8e
2 changed files with 2 additions and 14 deletions

View File

@ -80,8 +80,6 @@ class SharedStringsHelper
* *
* The XML file can be really big with sheets containing a lot of data. That is why * 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. * 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 * @return void
* @throws \Box\Spout\Common\Exception\IOException If sharedStrings.xml can't be read * @throws \Box\Spout\Common\Exception\IOException If sharedStrings.xml can't be read
@ -91,8 +89,7 @@ class SharedStringsHelper
$xmlReader = new XMLReader(); $xmlReader = new XMLReader();
$sharedStringIndex = 0; $sharedStringIndex = 0;
$sharedStringsFilePath = $this->getSharedStringsFilePath(); if ($xmlReader->openFileInZip($this->filePath, self::SHARED_STRINGS_XML_FILE_PATH) === false) {
if ($xmlReader->open($sharedStringsFilePath) === false) {
throw new IOException('Could not open "' . self::SHARED_STRINGS_XML_FILE_PATH . '".'); throw new IOException('Could not open "' . self::SHARED_STRINGS_XML_FILE_PATH . '".');
} }
@ -119,14 +116,6 @@ class SharedStringsHelper
$xmlReader->close(); $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 <sst> tag. * Returns the shared strings unique count, as specified in <sst> tag.
* *

View File

@ -128,8 +128,7 @@ class RowIterator implements IteratorInterface
{ {
$this->xmlReader->close(); $this->xmlReader->close();
$sheetDataFilePath = 'zip://' . $this->filePath . '#' . $this->sheetDataXMLFilePath; if ($this->xmlReader->openFileInZip($this->filePath, $this->sheetDataXMLFilePath) === false) {
if ($this->xmlReader->open($sheetDataFilePath) === false) {
throw new IOException("Could not open \"{$this->sheetDataXMLFilePath}\"."); throw new IOException("Could not open \"{$this->sheetDataXMLFilePath}\".");
} }