自定义cvs简易导出

2017-09-12 19:23:18来源:CSDN作者:qq_16618179人点击

分享
 public function downPcSearch($data)    {        if(count($data)>0){            set_time_limit(0);            ini_set('memory_limit','2048M');            $output = fopen('php://output', 'w') or die("can't open php://output");            header("Content-Type: application/csv");            header("Content-Disposition: attachment; filename=PC单号导出.(" .date("Ymd").").csv");            ob_end_clean();            $firstLine = array(                'pc_id' =>'PC单号',                'sku' =>'sku',                'end_status' =>'状态',                'shipmentid' =>'shipmentid',                'site_id' =>'站点',                'account_name' =>'账号',                'asin' =>'ASIN',                'seller_sku' =>'SellerSku',                'sku_name' =>'中文名称',                'create_time' =>'备货创建时间',                'export_tax_rebate' =>'是否退税',                'enterprise_dominant' =>'公司主体',                'needs_quantity' =>'需求数量',                'claim_arrive_time' =>'要求到货时间',                'seller_check_time' =>'销售确认时间',                'compliance_check_time' =>'合规审核时间',                'logistic_check_time' =>'物流预审时间',                'over_time' =>'备货取消时间',                'plan_create_time' =>'生成计划单时间',                'push_warehouse_time' =>'推送仓库时间',                'picking_time' =>'拣货确认时间',                'box_create_time' =>'录入箱唛数据时间',                'package_upload_time' =>'装箱确认时间',//                'pc_id' =>'平台计划取消时间',                'tran_create_time' =>'生成物流计划时间',                'pickup_op_time' =>'物流发货时间',                'create_user_id' =>'需求创建人',            );            fputcsv($output, array_values($firstLine));            foreach ($data as $_data) {                $_output = array();                foreach ($firstLine as $key => $val) {                    $_output[$key] = $_data[$key];                }                fputcsv($output, array_values($_output));            }            fclose($output) or die("can't close php://output");            exit;        }else{            echo "<script>alert('数据为空');history.go(-1)</script>";die;        }    }

最新文章

123

最新摄影

微信扫一扫

第七城市微信公众平台