public function test_parse() { $settings = new ParserSettings(); $parser = new RowParser($settings); $parsed = $parser->parse($this->mockRow()); $this->assertInstanceOf('Maatwebsite\\Clerk\\Excel\\Collections\\CellCollection', $parsed); $this->assertInstanceOf('Maatwebsite\\Clerk\\Excel\\Adapters\\PHPExcel\\Cell', $parsed->first()); $this->assertCount(3, $parsed); }
/** * @param PHPExcel_Worksheet $sheet * * @return RowCollection */ public function parse(PHPExcel_Worksheet $sheet) { // Init row collection $collection = new RowCollection(); // Set the sheet title $collection->setTitle($sheet->getTitle()); // Get the sheet heading row $heading = (new HeadingParser($this->settings))->parse($sheet); // Row parsers $parser = new RowParser($this->settings, $heading); foreach ($sheet->getRowIterator($this->getStartRow()) as $index => $row) { // Limit the results when needed if ($this->hasReachedLimit($index)) { break; } $collection->push($parser->parse($row)); } return $collection; }