1. 程式人生 > >PHP資料匯出excel表的外掛與運用

PHP資料匯出excel表的外掛與運用

外掛下載在我的這裡有我已經上傳了,自己下載,遇到問題可以在下方留言,

1、包放在 ThinkPHP -> Library -> Vendor;

2、前端:程式碼 <div class="btn-group" style="float: left; margin-top:25px;margin-left:10px;">                                     <a href="{:U('Home/User/export',array('username'=>I('get.username') , 'phone'=>I('get.phone')))}"                                        target="_blank" class="btn btn-danger">                                         匯出全部訂單                                     </a>                                 </div>

3、方法:public function export()     {        $users = M('user')->order('id desc')->select();        Vendor("PHPExcel.Excel#class");         \Excel::export($users,array('使用者ID', '預設地址ID', '備用', '推薦人ID', 'openid', '真實姓名', '暱稱', '年齡', '出生日期', '聯絡方式', 'password', 'token', 'avater', '性別', '城市', '省份', '縣', '詳細地址', '國家', '語言', 'subscribe', '使用者餘額', '積分', '歷史積分', '狀態', '是否認證', 'lastip', 'ctime', 'buy_num', '身份', '等級', '備註', '微訊號', '系統可用天數', 'ordernum', 'c_time', '系統更新時間', '結束時間', 'version', 'isbuy', 'upversion', 'isnew', 'time', '身份證', '一級分銷上級 id', '二級分銷上級 id', 'one_time', 'two_time', '推廣二維碼', '店鋪id'));     }

4、最後的陣列要與匯出資料表字段一一對應;不然導不出