- 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 (); Get total number of rows
- $highestColumn = $sheet->gethighestcolumn (); Total number of columns obtained
- $k = 0;
- Iterate through the Excel file, read one, insert a
- for ($j =2; $j <= $highestRow; $j + +)
- {
- $a = $objPHPExcel->getactivesheet ()->getcell ("a". $j)->getvalue ();//Get the value of column A
- $b = $objPHPExcel->getactivesheet ()->getcell ("B". $j)->getvalue ();//Get the value of column B
- $sql = "INSERT into table VALUES (". $a. ",". $b. ")";
- mysql_query ($sql);
- }
This article links http://www.cxybl.com/html/wlbc/Php/20130701/38844.html