/** * 导出 */ public function export() { $user = D('Home/Index'); $data = $user->queryByList(); $subject = "Excel导出测试"; $title = array("id", "姓名", "手机号码", "性别", "email"); exportExcel($data, $title, $subject); }
public function excelExport() { // $list = array( // array('id' => '1', 'username' => "*****@*****.**", 'password' => 'sucaihuo.com'), // array('id' => '2', 'username' => '*****@*****.**', 'password' => 'hjl666666'), // array('id' => '3', 'username' => '*****@*****.**', 'password' => 'zhangqirui'), // ); $list = M("user")->field("id,username,password")->order("id DESC")->limit(50)->select(); $title = array('ID', '用户名', '密码'); //设置要导出excel的表头 exportExcel($list, '素材火', $title); }
public function out() { $xlsName = CONTROLLER_NAME; $Field = 'id,total_money,tag,orderid,ship_price,score,coupon_money,uid'; if (isset($_GET['status'])) { $map['status'] = array('like', '%' . (int) I('status') . '%'); } else { $map['status'] = array('gt', 0); //有效订单 } $xlsCell = array(array('id', '编号'), array('orderid', '订单号'), array('tag', '支付订单号'), array('total_money', '实际金额'), array('ship_price', '运费'), array('score', '消耗积分'), array('coupon_money', '消耗优惠券金额'), array('uid', '用户uid')); $xlsModel = M($xlsName); $xlsData = $xlsModel->where($map)->Field($Field)->select(); if (!$xlsData) { $this->error('无数据'); } exportExcel($xlsName, $xlsCell, $xlsData); }
public function dataTable() { Doo::loadClassAt('html/DataTable', 'default'); Doo::loadClassAt('html/DooFormExt', 'default'); $dt = new DataTable(); $param['starttime'] = $this->getUrlVar('starttime', NULL); $param['endtime'] = $this->getUrlVar('endtime', NULL); //$param['bookid'] = $this->getUrlVar('bookid',NULL); $param['order'] = $this->getUrlVar('order', NULL); $param['bookname'] = $this->getUrlVar('bookname', NULL); //$param['booktypeid'] = $this->getUrlVar('booktypeid',0); $param['waimai'] = $this->getUrlVar('waimai', '2'); $param['shopname'] = $this->getUrlVar('shopname', ''); $export = $this->getUrlVar('export'); // 表头 $header = array('bookid' => array('name' => '菜品ID'), 'title' => array('name' => '菜品名称'), 'sum' => array('name' => '销量'), 'price' => array('name' => '微信单价'), 'totle' => array('name' => '总价')); //所有店列表 $shopNameList = DBproxy::getProcedure('Manage')->setDimension(2)->getShopName(); $shopNameOpt = '<select class="m-wrap" name="shopname" id="city-element"><option>全部门店</option>'; foreach ($shopNameList as $key => $value) { $selected = $this->getUrlVar('shopname') == $value['cityid'] . ',' . $value['shopname'] ? 'selected=selected' : ''; $shopNameOpt .= '<option ' . $selected . ' value="' . $value['cityid'] . ',' . $value['shopname'] . '">' . $value['cityNshopname'] . '</option>'; } $shopNameOpt .= '</select>'; $res = DBproxy::getProcedure('Manage')->setDimension(2)->queryOrderHit($param); $sum = 0; foreach ($res['data'] as $key => $value) { $sum += $value['sum']; $res['data'][$key]['totle'] = $value['sum'] * $value['price']; } // 生产表格 $content = $dt->setTitle('')->setAttr(array('class' => 'table table-hover ', 'id' => 'js-queryTable '))->setHeader($header)->setData($res['data'])->setTopContent('')->setBottomContent('')->setDefaultValue('unkown')->render(false); //查询表单 $form = new DooFormExt(array('method' => 'get', 'renderFormat' => 'html', 'action' => '', 'attributes' => array('id' => 'js-get-form', 'class' => 'form-horizontal'), 'elements' => array('starttime' => array('text', array('left' => ' ', 'hide-label' => true, 'div' => false, 'placeholder' => '开始日期', 'attributes' => array('class' => "m-wrap", "onClick" => "WdatePicker()"), 'value' => $this->getUrlVar('starttime'))), 'endtime' => array('text', array('left' => ' ', 'hide-label' => true, 'div' => false, 'placeholder' => '结束日期', 'attributes' => array('class' => "m-wrap", "onClick" => "WdatePicker({maxDate:'%y-%M-%d'})"), 'value' => $this->getUrlVar('endtime'))), 'shopname' => array('display', array('left' => '', 'hide-label' => true, 'div' => false, 'attributes' => array('class' => 'small m-wrap'), 'content' => $shopNameOpt)), 'bookname' => array('text', array('left' => ' ', 'hide-label' => true, 'div' => false, 'placeholder' => '菜品名称', 'attributes' => array('class' => "m-wrap"), 'value' => $this->getUrlVar('bookname'))), 'waimai' => array('select', array('left' => ' 是否外卖', 'hide-label' => true, 'div' => false, 'attributes' => array('class' => 'small m-wrap'), 'multioptions' => array('2' => '全部', '1' => '是', '0' => '否'), 'value' => $this->getUrlVar('waimai'))), 'order' => array('select', array('left' => ' 点击量排序', 'hide-label' => true, 'div' => false, 'attributes' => array('class' => 'small m-wrap'), 'multioptions' => array('desc' => '多', 'asc' => '少'), 'value' => $this->getUrlVar('order'))), 'search' => array('button', array('div' => false, 'label' => '<i class="icon-search"></i>查询', 'attributes' => array('class' => "btn blue"), 'value' => 1)), 'export' => array('button', array('div' => false, 'label' => ' <i class="icon-export"></i> 导出', 'attributes' => array('class' => "btn black"), 'value' => 1))))); $sumDiv = '销售总数量:' . $sum; $content .= $sumDiv; //export if (trim($export) == 1) { exportExcel($content); exit; } // 显示模版 $this->contentlayoutRender($form->render() . $content); }
/** * 产品导出 */ public function productExport() { $Product = D('Product'); if (IS_POST) { $order_by_name = I('post.order_by_name'); $order_by = I('post.order_by'); if (I("post.menshi") != '') { $menshi = I("post.menshi"); $sql = "SELECT gy.pid FROM __MALL_fahuo_gongying AS gy\n LEFT JOIN __MALL_fahuo AS fh ON gy.fid = fh.id\n WHERE fh.title = '{$menshi}'"; $product_list = $this->MallDb->list_query($sql); foreach ($product_list as $k => $v) { $product_arr[] = $v['pid']; } $product_str = Tools::arr2str($product_arr); $map['itemid'] = ['in', $product_str]; } else { $menshi = ""; } if (I("post.username") != '') { $map['username'] = I("post.username"); } if (I("post.cj") != '') { $map['cj'] = I("post.cj"); } if (I("post.company") != '') { $map['company'] = I("post.company"); } $data = $Product->field(["itemid", "title", "model", "standard", "price", "diprice", "username", "cj", "company", "addtime"])->where($map)->order("{$order_by_name} {$order_by}")->select(); foreach ($data as $k => $v) { $data[$k]['addtime'] = date("Y-m-d H:i:s", $v['addtime']); $data[$k]['total'] = count(D('Trade')->where("p_id = {$v['itemid']}")->field("itemid")->select()); $data[$k]['menshi'] = $menshi; } $fileName = "产品导出"; $headArr = ["编号", "标题", "成份", "规格", "价格", "底价", "用户名", "厂家", "公司", "发布日期", "销售数", "门市"]; if (count($data) == 0) { echo "没有数据可以导出"; exit; } else { exportExcel($fileName, $headArr, $data); exit; } } $this->display(); }
public function downloadalllist() { if (session('is_admin') != 1) { header('Location: /guess/stats'); exit; } $products = C('products'); $invites = M('invite')->select(); $users = M('users')->order('ctime desc')->select(); $user_hit_count = 0; foreach ($users as $index => $u) { if ($u['product_id'] > 0) { $users[$index]['product'] = $products[$u['product_id']]; } $users[$index]['invite_accept_count'] = array(); $users[$index]['invite_count'] = 0; foreach ($invites as $i) { if ($i['sender_id'] == $u['id']) { $users[$index]['invite_count']++; if ($i['newer_id'] > 0) { $users[$index]['invite_accept_count'][$i['newer_id']] = $i['newer_id']; } } } $users[$index]['invite_accept_count'] = count($users[$index]['invite_accept_count']); if ($u['hit'] == 1) { $user_hit_count++; } } exportExcel($users); }
/** * 导出用户数据 */ public function memberExcel() { // $Member = D('Member'); $map['status'] = ['in', '2,3,4']; $month_start = I('get.month_start'); $month_end = I('get.month_end'); $mouth_solt = get_month_solt($month_start, $month_end); if (I('get.type') == 'export') { foreach ($mouth_solt as $k => $v) { $time_start = $mouth_solt[1]['start']['ts']; $time_end = $mouth_solt[$k]['end']['ts']; $map['regtime'] = [between, [$time_start, $time_end]]; $mouth_solt_data[$k]['mouth_solt'] = $v; $x = $Member->field('userid')->where($map)->select(); $mouth_solt_data[$k]['count'] = count($x); } $time_start = $mouth_solt[1]['start']['ts']; $time_end = $mouth_solt_data[$k]['mouth_solt']['end']['ts']; $sql = "SELECT a.username,a.truename,a.mobile,a.areaid,b.areaname FROM destoon_member AS a LEFT JOIN destoon_area AS b ON (a.areaid = b.areaid) where a.regtime between {$time_start} and {$time_end} "; $data = queryMysql($sql); if (!empty($data)) { foreach ($data as $k => $v) { $member_info[$k]['username'] = $v['username']; $member_info[$k]['truename'] = $v['truename']; $member_info[$k]['mobile'] = $v['mobile']; $arealist = getAreaFullNameFromAreaID($v['areaid']); $member_info[$k]['areaname'] = arr2str($arealist, ''); } $fileName = "会员信息"; $headArr = array('用户名', '姓名', '联系方式', '所在地区'); exportExcel($fileName, $headArr, $member_info); //数据导出 } else { $this->error('错误'); } } }
<?php /** * v3-b12 * *by 好商城V3 www.33hao.com 运营版 **/ function exportExcel($filename, $content) { header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-Type: application/vnd.ms-execl"); header("Content-Type: application/force-download"); header("Content-Type: application/download"); header("Content-Disposition: attachment; filename=" . $filename); header("Content-Transfer-Encoding: binary"); header("Pragma: no-cache"); header("Expires: 0"); echo $content; } $str = "地区ID\t地区名称\t自营店ID\t自营店名称\t级别\t是否有效(0无效1有效)\n"; //$str = iconv('utf-8','gb2312',$str); if (is_array($store_area_list)) { foreach ($store_area_list as $key => $val) { $str = $str . $val['area_id'] . "\t" . $area_array[$val['area_id']] . "\t" . $val['store_id'] . "\t" . $store_array[$val['store_id']] . "\t" . $val['area_level'] . "\t" . $val['state'] . "\n"; } } $filename = time() . '.xls'; exportExcel($filename, $str);
/** * 各县交易额数据导出 * 返回excel表 */ public function businessExport() { $area = D('Area'); if (I('get.type') == 'export') { $data = $this->getPidByCity(); foreach ($data as $k => $v) { if ($v['parentid'] != 0) { $where['areaid'] = array('eq', $v['parentid']); $data_area = $area->field('parentid,areaname')->where($where)->select(); foreach ($data_area as $k2 => $v2) { $data[$k]['provice'] = $v2['areaname']; //获取省名 } } } $x = 1; //数据重组 foreach ($data as $key => $val) { $tmp[$key]['id'] = $x++; $tmp[$key]['provice'] = $val['provice']; $tmp[$key]['city'] = $val['city']; $tmp[$key]['county'] = $val['county']; $tmp[$key]['totalmoney'] = $val['totalmoney']; $tmp[$key]['truename'] = $val['truename']; $tmp[$key]['count'] = $val['count']; } $fileName = "合作商交易额及下线客户统计"; $headArr = array('ID', '省', '城市', '区县', '交易额', '合作商', '线下客户'); exportExcel($fileName, $headArr, $tmp); //数据导出 } }
<?php include 'functions.php'; switch ($_REQUEST['action']) { case 'compara': compara($_POST["modelos"][0], $_POST["modelos"][1]); break; case 'export': switch ($_GET['tipo']) { case 'excel': exportExcel($_GET['html']); break; default: break; } break; default: break; }
$teleOrder = new TeleOrder(); $data = $teleOrder->getOnePage($sql, $pageNum); // echo $sql; echo json_encode(array('data' => $data)); } //导出excel if ($action == "exportExcel") { $endCallinDate = date("Y-m-d", strtotime("{$endCallinDate} + 1 day")); $sql = "select * from teleRecord where dateOfTele >= '{$startCallinDate}' and dateOfTele <= '{$endCallinDate}' order by dateOfTele desc"; $teleOrder = new TeleOrder(); // $data = $teleOrder->getOnePage($sql, $pageNum); // echo $sql; // echo json_encode($data); // Create new PHPExcel object $outputData = $teleOrder->getRow($sql); exportExcel($outputData); echo sizeof($outputData); } //导出excel function exportExcel($outputData) { $objPHPExcel = new PHPExcel(); // echo json_encode($outputData); // print_r("<pre>"); // print_r($outputData); $objPHPExcel->setActiveSheetIndex(0)->setCellValue('A1', '呼入日期')->setCellValue('B1', '电话号码')->setCellValue('C1', '订单号码')->setCellValue('D1', '业务种类')->setCellValue('E1', '客服记录')->setCellValue('F1', '处理人')->setCellValue('G1', '处理日期'); $row = 2; $cellName = ''; foreach ($outputData as $order => $orderValue) { foreach ($orderValue as $columnName => $columnValue) { switch ($columnName) {
<?php require_once "admin_conn.php"; chkLogin(); $action = be("all", "action"); switch ($action) { case "editall": editall(); break; case "exportExcel": exportExcel(); break; case "info": headAdmin("电视直播管理"); info(); break; default: headAdmin("电视直播管理"); main(); break; } dispseObj(); function editall() { global $db; $t_id = be("arr", "t_id"); $ids = explode(",", $t_id); foreach ($ids as $id) { $tv_name = be("post", "tv_name" . $id); $tv_code = be("post", "tv_code" . $id); //var_dump($t_type);
public function dataTable() { Doo::loadClassAt('html/DataTable', 'default'); Doo::loadClassAt('html/DooFormExt', 'default'); $nowPage = $this->getCurPage(); $search = $this->getUrlVar('search'); if (trim($search) == 1) { // $nowPage = 1; } $param['starttime'] = $this->getUrlVar('starttime', NULL); $param['endtime'] = $this->getUrlVar('endtime', NULL); $wvalue = $this->getUrlVar('waimai', '-1'); $param['waimai'] = $wvalue == -1 ? '' : $wvalue; $param['status'] = $this->getUrlVar('status'); // $param['status'] = '4'; $param['phone'] = $this->getUrlVar('phone'); $param['id'] = $this->getUrlVar('orderid'); $param['city'] = $this->getUrlVar('city'); $param['booktype'] = $this->getUrlVar('booktype'); $param['pagesize'] = $nowPage . ',' . Doo::conf()->pagesize; $export = $this->getUrlVar('export'); if ($export == 1) { unset($param['pagesize']); } $res = DBproxy::getProcedure('Manage')->setDimension(2)->getOrder($param); $table = '<table class="table table-hover table-bordered" id="js-queryTable "> <thead> <tr> <th width="10%">店面</th> <th width="10%">订单号</th> <th width="10%">订单时间</th> <th width="10%">菜品</th> <th width="10%">价钱</th> <th width="10%">份量</th> <th width="5%">总价</th> <th width="10%">用户手机</th> <th width="5%" >可用状态</th> <th width="10%" >外卖地址</th> <th width="10%" >操作</th> </tr> </thead><tbody>'; foreach ($res['data'] as $key => $value) { $addr = trim($value[0]['addr']) != '' && $value[0]['waimai'] == 1 ? '      外卖地址:' . $value[0]['addr'] : ''; $row = count($value); foreach ($value as $vkey => $vvalue) { $table .= '<tr>'; if ($vkey == 0) { $table .= '<td rowspan=" ' . $row . ' " style="text-align: center" > ' . $value[0]['shopname'] . '</td>'; $table .= '<td rowspan=" ' . $row . ' " style="text-align: center" > ' . $value[0]['oid'] . ' </td>'; $table .= '<td rowspan=" ' . $row . ' " style="text-align: center" > ' . date("Y-m-d H:i:s", $value[0]['addtime']) . ' </td>'; } $table .= '<td style="text-align: center" > ' . $vvalue['title'] . ' </td>'; $table .= '<td style="text-align: center" > ' . $vvalue['wxprice'] . ' </td>'; $table .= '<td style="text-align: center" > ' . $vvalue['sum'] . ' </td>'; if ($vkey == 0) { $table .= '<td rowspan=" ' . $row . ' " style="text-align: center" > ¥' . $vvalue['allPrice'] . '</td>'; $table .= '<td rowspan=" ' . $row . ' " style="text-align: center" > ' . $vvalue['phone'] . '</td>'; $table .= '<td rowspan=" ' . $row . ' " style="text-align: center" > ' . $this->table_status($vvalue['status'], $key) . ' </td>'; $table .= '<td rowspan=" ' . $row . ' " style="text-align: center" > ' . $addr . ' </td>'; $table .= '<td rowspan=" ' . $row . ' " style="text-align: center" > ' . $this->table_action($vvalue['orderKeyId']) . ' </td>'; } $table .= '</tr>'; } $table .= '<tr> <td colspan="11" style=""></td></tr>'; } // D($res['total']); $table .= '</tbody></table><p>总数:' . $res['orderTotal'] . '</p>' . $this->pager($res['total']); //export if (trim($export) == 1) { exportExcel($table); exit; } //查询表单 $form = new DooFormExt(array('method' => 'get', 'renderFormat' => 'html', 'action' => '', 'attributes' => array('id' => 'js-get-form', 'class' => 'form-horizontal'), 'elements' => array('status' => array('select', array('left' => ' 订单状态:', 'hide-label' => true, 'div' => false, 'attributes' => array('class' => 'small m-wrap'), 'multioptions' => OrderController::$status, 'value' => $this->getUrlVar('status'))), 'starttime' => array('text', array('left' => ' ', 'hide-label' => true, 'div' => false, 'placeholder' => '开始日期', 'attributes' => array('class' => "m-wrap", "onClick" => "WdatePicker()"), 'value' => $this->getUrlVar('starttime'))), 'endtime' => array('text', array('left' => ' ', 'hide-label' => true, 'div' => false, 'placeholder' => '结束日期', 'attributes' => array('class' => "m-wrap", "onClick" => "WdatePicker({maxDate:'%y-%M-%d'})"), 'value' => $this->getUrlVar('endtime'))), 'waimai' => array('select', array('left' => ' 取餐方式', 'hide-label' => true, 'div' => false, 'attributes' => array('class' => 'small m-wrap'), 'multioptions' => OrderController::$waimaiStatus, 'value' => $this->getUrlVar('waimai'))), 'booktype' => array('select', array('left' => ' 餐类别:', 'hide-label' => true, 'div' => false, 'attributes' => array('class' => 'small m-wrap'), 'multioptions' => OrderController::$booktype, 'value' => $this->getUrlVar('booktype'))), 'city' => array('display', array('left' => ' 城市:', 'hide-label' => true, 'div' => false, 'attributes' => array('class' => 'small m-wrap'), 'content' => OrderController::$city, 'value' => $this->getUrlVar('city'))), 'phone' => array('text', array('hide-label' => true, 'div' => false, 'placeholder' => '11位手机号码', 'attributes' => array('class' => 'small m-wrap'), 'value' => $this->getUrlVar('phone'))), 'orderid' => array('text', array('hide-label' => true, 'div' => false, 'placeholder' => '订单号', 'attributes' => array('class' => 'small m-wrap'), 'value' => $this->getUrlVar('orderid'))), 'search' => array('button', array('div' => false, 'label' => '<i class="icon-search"></i>查询', 'attributes' => array('class' => "btn blue"), 'value' => 1)), 'export' => array('button', array('div' => false, 'label' => ' <i class="icon-export"></i> 导出', 'attributes' => array('class' => "btn black"), 'value' => 1))))); // 显示模版 $this->contentlayoutRender($form->render() . $table); }
public function index() { global $custom_config; if (IS_GET) { $type_id = I('type_id', 0, 'int'); $is_show = I('is_show', 0, 'int'); $store_role = I('store_role', 0, 'int'); $join_chain = I('join_chain', 0, 'int'); $supply_channels = I('supply_channels', 0, 'int'); $keryword = I('keyword'); $truename = $keryword; $where = "1=1"; if ($type_id) { $where .= " and type_id='{$type_id}' "; } if (isset($_GET['is_show'])) { $where .= " and is_show='{$is_show}' "; } else { $where .= " and is_show=1 "; } if ($store_role) { $where .= " and store_role='{$store_role}' "; } if ($join_chain) { $where .= " and join_chain='{$join_chain}' "; } if ($supply_channels) { $where .= " and find_in_set('{$supply_channels}',supply_channels)"; } if ($truename) { $where .= " and truename like '%{$truename}%'"; } } $userM = M('user'); //导出excel数据 if (isset($_GET['export'])) { $data = array(); $data[0] = array("真实姓名", "用户名", "性别", "手机号", "店铺名称", "地址", "注册时间"); $users = $userM->field("truename,username,sex,phone,store_name,province,city,area,address,street,addtime")->order('user_id desc')->where($where)->select(); $i = 1; foreach ($users as $uk => $uv) { $users[$uk]['user_address'] = user_province($uv['province']) . user_city($uv['city']) . user_area($uv['area']) . user_street($uv['street']) . $uv['address']; $data[$i]['truename'] = $users[$uk]['truename']; $data[$i]['username'] = $users[$uk]['username']; $data[$i]['sex'] = $users[$uk]['sex'] == 1 ? "男" : "女"; $data[$i]['phone'] = $users[$uk]['phone'] . " "; $data[$i]['store_name'] = $users[$uk]['store_name']; $data[$i]['user_address'] = $users[$uk]['user_address']; $data[$i]['addtime'] = date("Y-m-d H:i:s", $users[$uk]['addtime']); $i++; } exportExcel($data, "users"); return; } $count = $userM->where($where)->count(); // 查询满足要求的总记录数 $Page = new \Think\Page($count, 20); // 实例化分页类 传入总记录数和每页显示的记录数(20) $show = $Page->show(); // 分页显示输出 $users = $userM->order('user_id desc')->where($where)->limit($Page->firstRow . ',' . $Page->listRows)->select(); $this->assign('custom_config', $custom_config); $this->assign('users', $users); $this->assign('show', $show); $this->display(); }