概述1、导出csv文件 ?php require_once ( dirname (__FILE__) . /../include/common.inc.php ); $output = fopen( , w ) or die( cant open ); header( Content-Type: application/csv ); header( Content-Disposition: attachment; filename=认证列表.csv ); $a
1、导出csv文件 | require_once ( dirname (__file__) . "/../include/common.inc.PHP" ); | | $output = fopen( '' , 'w' ) or dIE( "can't open " ); | | header( 'Content-Type: application/csv' ); | | header( 'Content-disposition: attachment; filename="认证列表.csv"' ); | | iconv( 'utf-8' , 'gb2312' , '姓名' ), | | iconv( 'utf-8' , '电话' )//文件表头 | | fputcsv($output,$arrkeys); | | $sql = "SELECT * FROM dede_test" ; | | $dsql->Execute( 'me' ,$sql); | | while ($row = $dsql->GetArray( 'me' )){ | | $mobile= $row[ 'mobile' ]; //循环 | | fputcsv($output,$arrkeys); | | fclose($output) or dIE( "can't close " ); | |
2、导入xls文件 查看源码 打印代码帮助 | require_once ( dirname (__file__) . "/../include/common.inc.PHP" ); | | include_once( "excel/reader.PHP" ); | | $tmp = $_fileS[ 'file' ][ 'tmp_name' ]; | | ShowMsg( "请选择要导入的Excel文件!" , "test.PHP" ); | | $file_name = $save_path. date ( 'Ymdhis' ) . ".xls" ; | | if (copy($tmp,$file_name)) { | | $xls = new Spreadsheet_Excel_Reader(); | | $xls->setoutputEnCoding( 'utf-8' ); | | 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(); | | ShowMsg( "成功导入!" , "test.PHP" ); | | ShowMsg( "导入失败!" , "test.PHP" ); | |
dede
后台导出demo,点击下载 PHP导出xls 总结
以上是内存溢出为你收集整理的dedecms织梦后台增加批量上传和导出报表的功能全部内容,希望文章能够帮你解决dedecms织梦后台增加批量上传和导出报表的功能所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
评论列表(0条)