Download Phpexcel file, address: phpexcel.codeplex.com/
code example
Require_once ' phpexcel/classes/phpexcel.php ';
Require_once ' phpexcel/classes/phpexcel/iofactory.php ';
Require_once ' phpexcel/classes/phpexcel/reader/excel5.php ';
$objReader = Phpexcel_iofactory::createreader (' Excel5 ');//use excel2007 for 2007 format
$objPHPExcel = $objReader- >load ($filename); $filename can be an uploaded file, or a specified file
$sheet = $objPHPExcel->getsheet (0);
$highestRow = $sheet->gethighestrow (); The total number of
$highestColumn = $sheet->gethighestcolumn ();
$k = 0;
Iterate through the Excel file, read one, insert a for
($j =2; $j <= $highestRow; $j + +)
{
$a = $objPHPExcel->getactivesheet ( )->getcell ("a". $j)->getvalue ()//Gets the value of column a
$b = $objPHPExcel->getactivesheet ()->getcell ("B". $j)- >getvalue ()//Gets the value of column B
$sql = "INSERT into table values (". $a. ",". $b. ")";
mysql_query ($sql);
This article uses the Phpexcel class to implement Excel into the MySQL database function (instance code) is a small series to share all the content, I hope to give you a reference, but also hope that we support cloud habitat community.