Instance: 1. import the excel file require_once ("db. php "); // reference the database instantiation class require_once (" reader. php "); // $ excel $ data = new Spreadsheet_Excel_Reader (); // instantiate the class $ data-> setOutputEncoding ('utf-8 '); // set the encoding $ data-> read ($ _ FILES ["excel"] ["tmp_name"]); // read the excel temporary file if ($ data-> sheets [0] ['numrows ']> 0) {// determine whether the number of rows in the excel file is greater than 0. $ data-> Sheet [0] ['numrows '] indicates the total number of rows in the excel file for ($ I = 2; $ I <= $ data-> sheets [0] ['numrows ']; $ I ++) {// insert execl data into the database $ I indicates reading from row $ I of excel $ SQL = "insert into 'user' ('user _ name', 'phone ', 'User _ email ', 'Password') values (' {$ data-> sheets [0] ['cells '] [$ I] [1]}', // $ I is the row number '{$ data-> sheets [0] ['cells'] [$ I] [2]} 'in excel. '{$ data-> sheets [0] ['cells'] [$ I] [3]} ', '123 ')"; $ db-> query ($ SQL) ;}2 importing an excel file with multiple sheets is actually the same as importing a sheet. If there are two sheets (and so on) require_once ("db. php "); // reference the database instantiation class require_once (" reader. php "); // $ excel $ data = new Spreadsheet_Excel_Reader (); // instantiate the class $ data-> setOutputEncoding ('utf-8 '); // set the encoding $ data-> read ($ _ FILES ["excel"] ["tmp_name"]); // read the excel temporary file if ($ data-> sheets [0] ['numrows ']> 0) {// determine whether the number of rows in excel is greater than 0. $ data-> Sheet [0] ['numrows '] indicates the total number of rows in excel. Here, $ data-> Sheet [0] the first sheet for ($ I = 2; $ I <= $ data-> sheets [0] ['numrows ']; $ I ++) {// insert execl data into the database $ I indicates reading from row $ I of excel $ SQL = "insert into 'user' ('user _ name', 'phone ', 'User _ email ', 'Password') values (' {$ data-> sheets [0] ['cells '] [$ I] [1]}', // $ I is the row number '{$ data-> sheets [0] ['cells'] [$ I] [2]} 'in excel. '{$ data-> sheets [0] ['cells'] [$ I] [3]} ', '123 ')"; $ db-> query ($ SQL);} if ($ data-> sheets [1] ['numrows ']> 0) {// determine whether the number of rows in excel is greater than 0. $ data-> Sheet [0] ['numrows '] indicates the total number of rows in excel. Here, $ data-> Sheet [1] the second sheets for ($ I = 2; $ I <= $ data-> sheets [1] ['numrows ']; $ I ++) {// insert execl data into the database $ I indicates reading from row $ I of excel $ SQL = "insert into 'user' ('user _ name', 'phone ', 'User _ email ', 'Password') values (' {$ data-> sheets [1] ['cells '] [$ I] [1]}', // $ I is the row number '{$ data-> sheets [1] ['cells'] [$ I] [2]} 'in excel. '{$ data-> sheets [1] ['cells'] [$ I] [3]} ', '123 ')"; $ db-> query ($ SQL );}}