• execl csv导出


    方维js方法:

    function
    export_csv() { var inputs = $(".search_row").find("input:[type!='checkbox']"); var checkboxs = $(".search_row").find("input:[type='checkbox']:checked"); var selects = $(".search_row").find("select"); var param = ''; for(i=0;i<inputs.length;i++) { if(inputs[i].name!='m'&&inputs[i].name!='a') param += "&"+inputs[i].name+"="+$(inputs[i]).val(); } for(i=0;i<checkboxs.length;i++) { param += "&"+checkboxs[i].name+"="+$(checkboxs[i]).val(); } for(i=0;i<selects.length;i++) { param += "&"+selects[i].name+"="+$(selects[i]).val(); } var url= ROOT+"?"+VAR_MODULE+"="+MODULE_NAME+"&"+VAR_ACTION+"=export_csv"; alert(url); location.href = url+param; }


    php 写法:

           if($page == 1)
                $content = iconv("utf-8","utf-8","编号,部门,姓名,手机,所属角色,提成系数(%),投资人人数,可以用余额,状态,最后登录时间,最后登录IP");
        
                if($page==1)
                    $content = $content . " ";
                
                foreach($list as $k=>$v)
                {
                    $export_value['id'] =  iconv('utf-8','utf-8','"' . $v['id'] . '"');
                    $export_value['name'] = iconv('utf-8','utf-8','"' . $v['adm_name'] . '"');
                    $export_value['real_name'] = iconv('utf-8','utf-8','"' . $v['real_name'] . '"');
                    $export_value['mobile'] = iconv('utf-8','utf-8','"' . $v['mobile'] . '"');
                    $export_value['role'] = iconv('utf-8','utf-8','"' . M("Role")->where("id=".$v['role_id'])->getField("name") . '"');
                    $export_value['rate'] = iconv('utf-8','utf-8','"' . $v['referrals_rate'] . '"');
                    $export_value['rcount'] = iconv('utf-8','utf-8','"' . $v['referrals_count'] . '"');
                    $export_value['money'] = iconv('utf-8','utf-8','"' . $v['referrals_money'] . '"');
                    $export_value['status'] = iconv('utf-8','utf-8','"' . ($v['is_effect']== 1 ? "有效": "无效") . '"');
                    $export_value['time'] = iconv('utf-8','utf-8','"' . to_date($v['login_time']) . '"');
                    $export_value['ip'] = iconv('utf-8','utf-8','"' . $v['login_ip'] . '"');
                    
                    $content .= implode(",", $export_value) . " ";
                }
                header("Content-Disposition: attachment; filename=部门.csv");
                echo $content;
                     




  • 相关阅读:
    Python sys.argv用法详解及应用
    Python map() 函数
    Python中enumerate用法详解
    闭包,作用域链,垃圾回收,内存泄露
    jQuery 常用代码集锦
    关于作用域和作用域链最完整的简述
    git 合并commit
    apollo-client
    关于对称加密和解密
    接口校验机制
  • 原文地址:https://www.cnblogs.com/hnbiao/p/6014998.html
Copyright © 2020-2023  润新知