php简单生成excel

作者: 分类: php 时间: 2016-05-24 评论: 暂无评论
class Excel
{
    /**
     * 生成excel表格
     * @param array $title  表格的 th
     * @param array $data   表格数据 td
     */
    public static function getExcel($title=array(), $data=array())
    {
        header("Content-type:application/vnd.ms-excel");
        header("Content-Disposition:filename=" . date('Y年m月d日') . ".xls");
        header('Pragma: no-cache');
        header('Expires: 0');

       // echo iconv('utf-8', 'gbk', implode("\t", $title)), "\n"; 转码需要权限 chmod -R 777
        echo  implode("\t", $title), "\n";
        foreach ($data as $value) {
            echo implode("\t", $value), "\n";
        }
    }
}
标签: none

订阅本站(RSS)