后台view文件index
<a href="javascript:;" class="btn btn-danger btn-export {:$auth->check('obo/order/export')?'':'hide'}" data-url="{:url('obo/order/export')}" title="导出成功订单" >导出</a>
js
$(document).on("click", ".btn-export", function () { var url = $(this).attr('data-url'); console.log(url); window.open(url); });
php
use appcommonutilExcel;public function export() { $model = (new appcommonmodelOrder()); $excel = (new Excel($model, [], [])); $data = (new appcommonmodelOrder())->getDb() ->where(['succ'=>1]) // ->join('user u', 'a.user_id = u.id', 'INNER') // 添加需要的字段 ->field('id as 我想要的id') ->order('id desc') ->select(); $excel->setData('订单', (array)$data); $excel->downloadExcel('订单', 'Xlsx'); exit(); }
希望以上内容对你有所帮助!如果还有其他问题,请随时提问。 各类知识收集 拥有多年CMS企业建站经验,对 iCMS, Fastadmin, ClassCMS, LeCMS, PbootCMS, PHPCMS, 易优CMS, YzmCMS, 讯睿CMS, 极致CMS, Wordpress, HkCMS, YznCMS, WellCMS, ThinkCMF, 等各类cms的相互转化,程序开发,网站制作,bug修复,程序杀毒,插件定制都可以提供最佳解决方案。