笔记 · · 982 阅读

table 实现 excel 导出

table excel
table 实现 excel 导出

public function tableexcel()

{

    $list     = db('ecword')->limit(10000)->select();

    $strTable = '';

    $strTable .= '';

    $strTable .= 'id';

    $strTable .= '唯一标识';

    $strTable .= '英文';

    $strTable .= '中文';

    $strTable .= '添加时间';

    $strTable .= '状态';

    $strTable .= '';

    foreach ($list as $k => $val) {

        $strTable .= '';

        $strTable .= ' ' . $val['id'] . '';

        $strTable .= '' . $val['apid'] . ' ';

        $strTable .= '' . $val['english'] . '';

        $strTable .= '' . $val['chinese'] . '';

        $strTable .= '' . date('Y-m-d H:i:s', $val['add_time']) . '';

        $strTable .= '' . $val['status'] . '';

        $strTable .= '';

    }

    $strTable .= '';

    $filename = 'ecword';

    header("Content-type: application/vnd.ms-excel");

    header("Content-Type: application/force-download");

    header("Content-Disposition: attachment; filename=" . $filename . "_" . date('Y-m-d') . ".xls");

    header('Expires:0');

    header('Pragma:public');

    echo '' . $strTable . '';

    }

做tpshop商城后台数据导出的时候出现超时错误,然后找到源码,发现其没用PHPExcel等实现数据导出,

然后就根据他写的table格式自己写了一个方法测试,可实现excel文件导出。
0 评论

评论

还没有评论,来说两句吧