php导出excel最简单的办法,无需phpexcel

    public function  exportDayInner(){
            $start_date = input('start');
            $end_date = input('end');
            $innerdata = Db::table('inner')
                ->whereTime('add_date', 'between', [$start_date,$end_date])
                ->where('inner.depart_id',session('depart_id'))
                ->join('goods','inner.goods_id = goods.id')
                ->join('storage','storage.id = inner.storage_id')
                ->join('supplier','supplier.id = inner.supplier_id')
                ->join('user','user.id = inner.user_id')
                //->limit(5)
                ->order('inner.id desc')
                ->field('goods_name,add_date,storage_name,supplier_name,real_name,num,inner.price')
                ->select();
            $table = '';
            $table .= "<table>
                <thead>
                    <tr>
                        <th class='name'>名称</th>
                        <th class='name'>入库日期</th>
                        <th class='name'>入库库位</th>
                        <th class='name'>供货商</th>
                        <th class='name'>入库人</th>
                        <th class='name'>数量</th>
                        <th class='name'>单价</th>
                    </tr>
                </thead>
                <tbody>";
            foreach ($innerdata as $v) {
                $table .= "<tr>
                        <td class='name'>{$v['goods_name']}</td>
                        <td class='name'>{$v['add_date']}</td>
                        <td class='name'>{$v['storage_name']}</td>
                        <td class='name'>{$v['supplier_name']}</td>
                        <td class='name'>{$v['real_name']}</td>
                        <td class='name'>{$v['num']}</td>
                        <td class='name'>{$v['price']}</td>
                    </tr>";
            }
            $table .= "</tbody>
            </table>";
    //通过header头控制输出excel表格
                header("Pragma: public");  
            header("Expires: 0");  
            header("Cache-Control:must-revalidate, post-check=0, pre-check=0");  
            header("Content-Type:application/force-download");  
            header("Content-Type:application/vnd.ms-execl");  
            header("Content-Type:application/octet-stream");  
            header("Content-Type:application/download");;  
            header('Content-Disposition:attachment;filename="入库明细表.xls"');  
            header("Content-Transfer-Encoding:binary");  
            echo $table;
        }
http://www.cankaojishu.com/
  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值