How can I count no of row excel file in PHP, it not working properly after using this code?
My PHP code:
<?php if(isset($_FILES["excel_file"]["name"])) { $path = $_FILES["excel_file"]["tmp_name"]; $object = PHPExcel_IOFactory::load($path); foreach($object->getWorksheetIterator() as $worksheet) { $highestRow = $worksheet->getHighestRow(); echo $highestRow; } } ?>
Apply this code:
<?php $sheetData = $object->getActiveSheet()->toArray(null,true,true,true); echo count($sheetData); ?>
For example:
<?php if(isset($_FILES["excel_file"]["name"])) { $path = $_FILES["excel_file"]["tmp_name"]; $object = PHPExcel_IOFactory::load($path); $sheetData = $object->getActiveSheet()->toArray(null,true,true,true); echo count($sheetData); } ?>
Question and answer is powered by AnsPress.io