php导出excel方法

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

        header("Content-Disposition: attachment; filename=list.xls"); // 表名

        header("Pragma: no-cache"); // 缓存

        header("Expires: 0");

        $sepcol = " \t ";   // 分列;

        $sepbr = "\n";  // 分行


        $info = array();

        $info[0] = array('server','opentime');
        $info[1] = array('666',date('Y/m/d-H:i:s',time()));
        $info[2] = array('6666',date('Y/m/d-H:i:s',time()));
        $info[3] = array('6666',date('Y/m/d-H:i:s',time()));
        $info[4] = array('66666',date('Y/m/d-H:i:s',time()));
        $info[5] = array('666666',date('Y/m/d-H:i:s',time()));

        foreach ($info as $key) { 

            foreach ($key as $value) {   // 一行

                echo mb_convert_encoding($value,"GBK","utf-8").$sepcol;  // 分列

            }

            echo $sepbr;//分行

        }

        exit;

你可能感兴趣的:(php导出excel方法)