<?phperror_reporting (e_all ^ e_notice); $img = Base64_decode ($base); $a = file_put_contents ('./test.jpg ', $img);// The number of bytes returned is print_r ($a); Require_once ' sdk/phpexcel.php ';///** the date in Excel is formatted to convert *///function GetData ($val) {//$jd = GREGORIANTOJD (1, 1, 1970);//$gregorian = Jdtogregorian ($jd +intval ($val) -25569);//return $gregorian;/** display format "month/day/year" "*///} $filePath = './excel/5a4b301c7124e.xls ';//var_dump (file_exists ($filePath)); $PHPExcel = new Phpexcel ();/** The default is to read Excel with excel2007, if the format is not correct, use the previous version to read */$PHPReader = new phpexcel_reader_excel2007 (); if (! $PHPReader->canread ($ FilePath) {$PHPReader = new Phpexcel_reader_excel5 (); if (! $PHPReader->canread ($filePath)) {echo ' no Excel '; return; }} $PHPExcel = $PHPReader->load ($filePath);/** reads the first worksheet in an Excel file */$currentSheet = $PHPExcel->getsheet (0);/** Get the largest column number */$allColumn = $currentSheet->gethighestcolumn ();/** get total number of lines */$allRow = $currentSheet->gethighestrow ( );/** starts the output from the second line because the first behavior in the Excel table is column name */for ($currentRow = 2; $currEntrow <= $allRow, $currentRow + +) {/** start output from column A/for ($currentColumn = ' a '; $currentColumn <= $allColumn; $currentC olumn++) {$val = $currentSheet->getcellbycolumnandrow (ord ($currentColumn)-+, $currentRow)->getvalue ();/**or D () Convert the character to decimal number */if ($currentColumn = = ' A ') {//Echo GetData ($val). " \ t "; }else{//echo $val; /** if the output character is garbled, the output will need to be encoded with the ICONV function to convert the GB2312 encoding into UTF-8 encoded output *///echo iconv (' Utf-8 ', ' gb2312 ', $val). " \ t "; $infos [$currentColumn]=iconv (' utf-8 ', ' gb2312 ', $val); }}//echo "</br>"; $item =array (); $item [' title ']= $infos [' C ']; $item [' Barcode ']= $infos [' D ']; $item [' default_image_id ']= $infos [' F ']; $item [' Store ']= $infos [' H ']; $item [' Price ']= $infos [' I ']; $item [' Offline_price ']= $infos [' J ']; $item [' shop_id ']= $infos [' K ']; $item [' desc ']= $infos [' L ']; Var_dump ($item); Exit ();} Var_dump ($info); echo "\ n";? >
PHP import Excel into MySQL database