PHPExcel生成垃圾

时间:2013-01-22 09:48:08

标签: phpexcel

我正在尝试使用PHPExcel库生成Excel文档。

class product_specification_order extends DBHelper
{
    static $PK = 'orderID';

    static function xls($id){
       require_once('../lib/PHPExcel.php');
       $objPHPExcel = new PHPExcel();
       $objPHPExcel->setActiveSheetIndex(0);
       return $objPHPExcel;
    }
 }

然后,我有generatepecxls.php文件

if (empty($_REQUEST['id']))
    die("Wrong ID");
//output xls

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/octet-stream");
header("Content-Type: application/download");;
header("Content-Disposition: attachment;filename=File.xls");
header("Content-Transfer-Encoding: binary");

$objPHPExcel = product_specification_order::xls($_REQUEST['id']);
$objWriter = new PHPExcel_Writer_Excel5($objPHPExcel);    //  (I want the output for objWriter)
///print_r($objWriter);
$objWriter->save('php://output');

我得到的输出是垃圾。

0 个答案:

没有答案