I have a excel file with the extension .xlsx. I need to read this file and save into database. how to do this. I have no idea about this. plese guide me how to do step by step. Im using yii2 basic version.
Please use below extension and example code.
https://github.com/PHPOffice/PHPExcel
$tmpfname = "test.xlsx";
$excelReader = PHPExcel_IOFactory::createReaderForFile($tmpfname);
$excelObj = $excelReader->load($tmpfname);
$worksheet = $excelObj->getSheet(0);
$lastRow = $worksheet->getHighestRow();
echo "<table>";
for ($row = 1; $row <= $lastRow; $row++) {
echo "<tr><td>";
echo $worksheet->getCell('A'.$row)->getValue();
echo "</td><td>";
echo $worksheet->getCell('B'.$row)->getValue();
echo "</td><tr>";
}
echo "</table>";