PHPExcel已经被废弃在PHP7.2中已经无法获取更新,官方重新开了一个新包phpspreadsheet
composer安装:
composer require phpoffice/phpspreadsheet
一,导出,
1,view中:
<a href="#" class="label label-primary set" style="margin-right: 80px;float: right;margin-bottom: 6px;line-height: 20px" id="daochu">导出</a>
<script>
$('#daochu').click(function () {
if ($('#addtime').val() == ''){
layer.msg('请选择时间范围', {time : 1000});
return false;
}
var url= "{:url('admin/Orders/outExcel')}"+'?addtime='+$('#addtime').val()+'&order_num='+$('#order_num').val()+'&user_name='+$("#user_name").val()+"&addr_name="+$("#addr_name").val()+'&goods_type='+$("#goods_type").val()+"&order_status="+$("#order_status").val();
$('#daochu').attr('href',url);
})
</script>
,2,在控制器中写方法
public function outExcel(){
$param = input();
$where = [];
$where['a.order_status'] = ['between',[1,7]];
if (isset($param['order_num']) && !empty($param['order_num']))$where['a.order_num'] = $param['order_num'];
if (isset($param['order_status']) && !empty($param['order_status']))$where['a.order_status'] = $param['order_status'];
if (isset($param['addr_name']) && !empty($param['addr_name']))$where['a.addr_