How do I find out how many rows I have loaded using PHPSpreadsheet\Reader\Xlsx::load()
method?
I cannot find methods (or properties) for getting row count in Spreadsheet or Worksheet classes either.
BTW I am using following code:
$filename = 'test.xlsx';
$inputFileType = \PhpOffice\PhpSpreadsheet\IOFactory::identify($filename);
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($inputFileType);
$reader->setReadDataOnly(true);
$reader->setLoadSheetsOnly($sheet);
$this->spreadsheet = $reader->load($filename);
$this->worksheet = $this->spreadsheet->getActiveSheet();
Using the worksheet's getHighestRow()
method
$highestRow = $this->spreadsheet->getActiveSheet()->getHighestRow();
or getHighestDataRow()
if you're only interested in rows where cells contain data and not any blank rows at the end of the worksheet