/**
  *  Parse the rows
  * @return RowCollection
  */
 protected function parseRows()
 {
     // Set empty parsedRow array
     $parsedRows = new RowCollection();
     // set sheet title
     $parsedRows->setTitle($this->excel->getActiveSheet()->getTitle());
     // Get the start row
     $startRow = $this->getStartRow();
     try {
         $rows = $this->worksheet->getRowIterator($startRow);
     } catch (PHPExcel_Exception $e) {
         $rows = [];
     }
     // Loop through the rows inside the worksheet
     foreach ($rows as $this->row) {
         // Limit the results when needed
         if ($this->hasReachedLimit()) {
             break;
         }
         // Push the parsed cells inside the parsed rows
         $parsedRows->push($this->parseCells());
         // Count the rows
         $this->currentRow++;
     }
     // Return the parsed array
     return $parsedRows;
 }
Exemplo n.º 2
0
 /**
  * Return cell value
  * @param  string $coordinate
  * @return string|null
  */
 protected function getCellValueByCoordinate($coordinate)
 {
     if ($this->sheet) {
         if (str_contains($coordinate, ':')) {
             // We want to get a range of cells
             $values = $this->sheet->rangeToArray($coordinate);
             return $values;
         } else {
             // We want 1 specific cell
             return $this->sheet->getCell($coordinate)->getValue();
         }
     }
     return null;
 }