public function test_parse_with_max_rows() { $settings = new ParserSettings(); $settings->setHasHeading(false); $settings->setMaxRows(1); $parser = new SheetParser($settings); $parsed = $parser->parse($this->mockSheet()); $this->assertInstanceOf('Maatwebsite\\Clerk\\Excel\\Collections\\RowCollection', $parsed); $this->assertEquals('mocked', $parsed->getTitle()); $this->assertCount(1, $parsed); }
/** * Parse the workbook. * * @param PHPExcel $workbook * * @return SheetCollection */ public function parse(PHPExcel $workbook) { // Init sheet collection $collection = new SheetCollection(); // Set the workbook title $collection->setTitle($workbook->getProperties()->getTitle()); // Worksheet parser $parser = new SheetParser($this->settings); // Loop through all worksheets foreach ($workbook->getWorksheetIterator() as $index => $worksheet) { if ($this->isSelected($index)) { // Push the sheet onto the workbook $collection->push($parser->parse($worksheet)); } } return $collection; }