Import phpexcel to excel to process big data, and import phpexcel to excel
First download the corresponding phpExcel package on the line of the https://github.com/PHPOffice/PHPExcel
After the download is complete, just take out the files and folders in the Classes folder.
Directly written to the PHPExcel file. The call is simple. Introduce phpExcel to transfer the corresponding excel file path.
Now upload the file to the specified directory and then load the uploaded excel file to read the file. when reading the file here, the array is not converted. Note: Sheet can be read multiple times. The php Upload value must be set to a large value and the upload timeout value must be set to a long value.
Header ('content-type: text/html; charset = UTF-8 '); // sets the page encoding require_once' phpexcel. class. php '; // introduce the file require_once' PHPExcel/IOFactory. php '; // introduce the file require_once 'phpexcel/Reader/excel2007.php '; // introduce the file $ uploadfile =$ _ FILES ['select _ file'] ['tmp _ name']; // obtain the uploaded file $ auid =$ _ SESSION ['auid']; $ date = date ('ymmd'); $ rand = rand ); $ _ month = str_replace ('-', '', $ date); $ file_name = str_pad ($ auid, 4, 0, STR_PAD_LEFT ). $ date. str_pad ($ rand, 4, 0, STR_PAD_LEFT).'.xlsx '; $ path_file = '.. /data/upload/file /'. $ file_name; // specify move_uploaded_file ($ uploadfile, $ path_file) in the Upload File directory; // File Upload $ inputFileType = PHPExcel_IOFactory: identify ($ path_file); $ objReader = PHPExcel_IOFactory :: createReader ($ inputFileType); $ objReader-> setReadDataOnly (true); // you only need to add this method to convert the table data format $ objPHPExcel = $ objReader-> load ($ path_file ); $ sheet_read_arr = array (); $ sheet_read_arr ["table 1"] = array ("B", "C "); $ sheet_read_arr ["Table 2"] = array ("B", "C"); $ sheet_read_arr ["Table 3"] = array ("B", "C "); $ list_aray = array (); foreach ($ sheet_read_arr as $ key => $ val) {$ currentSheet = $ objPHPExcel-> getSheetByName ($ key ); $ row_num = $ currentSheet-> getHighestRow (); for ($ I = 6; $ I <= $ row_num; $ I ++) {$ cell_values = array (); foreach ($ val as $ cell_val) {$ address = $ cell_val. $ I; // cell coordinates $ cell_values [] = $ currentSheet-> getCell ($ address)-> getFormattedValue ();} $ list_aray [] = $ cell_values ;}}