The following section describes how to use the phpexcel class to import mysql databases to excel (instance code ). I think it is quite good. now I will share it with you and give you a reference. Let's take a look at the phpexcel file. Address: phpexcel.codeplex.com/
Sample code
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 the specified file $ sheet = $ objPHPExcel-> getSheet (0); $ highestRow = $ sheet-> getHighestRow (); // get the total number of rows $ highestColumn = $ sheet-> getHighestColumn (); // get the total number of columns $ k = 0; // read the excel file cyclically and read one, insert a for ($ j = 2; $ j <= $ highestRow; $ j ++) {$ A = $ objPHPExcel-> getActiveSheet ()-> getCell ("". $ j)-> getValue (); // obtain the value of column A $ B = $ objPHPExcel-> getActiveSheet ()-> getCell ("B ". $ j)-> getValue (); // obtain the value of column B $ SQL = "INSERT INTO table VALUES (". $. ",". $ B. ")"; mysql_query ($ SQL );}
The above section uses the phpexcel class to import the mysql database in excel (instance code). it is all the content that I have shared with you. I hope to give you a reference and support.