I am trying to get the last row that contains data in an excel workbook. I've used the function getHighestDataRow() like other advices I got from the internet. But it only work for .xls file. When I save the file to .xlsx format, the function return the wrong value Below is my code:
$inputFileType = PHPExcel_IOFactory::identify($file);
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
$objReader->setReadDataOnly(true);
$objReader->setLoadSheetsOnly(0);
$objPHPExcel = $objReader->load($file);
$sheet = $objPHPExcel->getSheet(0);
$highestRow = $sheet->getHighestDataRow();
$highestColumn = $sheet->getHighestDataColumn();
$highestColumnIndex = PHPExcel_Cell::columnIndexFromString($highestColumn);
I've been looking for this problem for hours but still can't find the answer.