1、导出csv文件
PHP"> Execute('me',$sql); while($row = $dsql->GetArray('me')){ $name =$row['name']; $mobile= $row['mobile']; //循环 $arrkeys = array( iconv('utf-8',$name),$mobile) ); fputcsv($output,$arrkeys); } fclose($output) or die("can't close "); exit(); ?>
2、导入xls文件
PHP"> setOutputEncoding('utf-8'); $xls->read($file_name); for ($i=2; $i<=$xls->sheets[0]['numRows']; $i++) { $name = $xls->sheets[0]['cells'][$i][1]; $mobile = $xls->sheets[0]['cells'][$i][2] $data_values .= "('$name','$mobile'),"; } $data_values = substr($data_values,-1); $sql= "INSERT INTO dede_test (name,mobile) VALUES $data_values"; $dsql->ExecuteNoneQuery($sql); $lastInsertID = $dsql->GetLastID(); if($dsql){ ShowMsg("成功导入!","test.PHP"); }else{ ShowMsg("导入失败!","test.PHP"); } } exit(); ?>原文链接:https://www.f2er.com/dedecms/403843.html