Esempio n. 1
0
 /**
  * Returns whether another worksheet exists after the current worksheet.
  * The order is determined by the order of appearance in the [Content_Types].xml file.
  *
  * @param Worksheet|null $currentWorksheet The worksheet being currently read or null if reading has not started yet
  * @param Worksheet[] $allWorksheets A list of all worksheets in the XLSX file. Must contain at least one worksheet
  * @return bool Whether another worksheet exists after the current sheet
  */
 public function hasNextWorksheet($currentWorksheet, $allWorksheets)
 {
     return $currentWorksheet === null || $currentWorksheet->getWorksheetIndex() + 1 < count($allWorksheets);
 }
Esempio n. 2
0
 /**
  * Initializes the XMLReader object that reads worksheet data for the given worksheet.
  * If another worksheet was being read, it closes the reader before reopening it for the new worksheet.
  * The XMLReader is configured to be safe from billion laughs attack.
  *
  * @param Internal\XLSX\Worksheet $worksheet The worksheet to initialize the XMLReader with
  * @return void
  * @throws \Box\Spout\Common\Exception\IOException If the worksheet data XML cannot be read
  */
 protected function initXmlReaderForWorksheetData($worksheet)
 {
     // if changing worksheet and the XMLReader was initialized for the current worksheet
     if ($worksheet != $this->currentWorksheet && $this->xmlReader) {
         $this->xmlReader->close();
     } else {
         if (!$this->xmlReader) {
             $this->xmlReader = new \XMLReader();
         }
     }
     $worksheetDataXMLFilePath = $worksheet->getDataXmlFilePath();
     $worksheetDataFilePath = 'zip://' . $this->filePath . '#' . $worksheetDataXMLFilePath;
     if ($this->xmlReader->open($worksheetDataFilePath, null, LIBXML_NOENT | LIBXML_NONET) === false) {
         throw new IOException('Could not open "' . $worksheetDataXMLFilePath . '".');
     }
 }