PHPExcel
use PHPExcel to read excel file.
install it with composer .
$reader = Asan\PHPExcel\Excel::load('abc.xls', function(Asan\PHPExcel\Reader\Xls $reader) {
$count = $reader->count();
for($i=0;$i<=$count;$i++)
$reader->seek(50);
$current = $reader->current();
//make insert query as per need and execute it do it your ways
$insert="insert into tablename (`field1`,`field2`) values('".$current->field1."','".$current->field1."')";
mysqli_query($connection , $insertquery);
}
}
or else use this code to read xls file , and run insert or update query as per need
$reader = Asan\PHPExcel\Excel::load('abc.xls', function(Asan\PHPExcel\Reader\Xls $reader) {
//$reader->setRowLimit(5);
$reader->setColumnLimit(10);
//$reader->setSheetIndex(1);
});
foreach ($reader as $row) {
//make insert query as per need and execute it do it your ways
$insert="insert into tablename (`field1`,`field2`) values('".$row->field1."','".$row->field1."')";
mysqli_query($connection , $insertquery);
}