本例測試中用的是ucenter x2.0和phpExcel v1.7.7php
1.將解壓的phpExcel文件放入到source/class下,並將phpExcel.php文件從新命名爲class_phpexcel.php瀏覽器
2.註釋掉source/class/class_core.php文件中import函數中拋出異常的那一行app
throw new Exception('Oops! System file lost: '.$filename);函數
3.調用生成excel測試代碼測試
header('Content-Type: application/vnd.ms-excel');
header("Content-Disposition:attachment; filename=demo.xls");
header('Cache-Control: max-age=0');
$objPHPExcel = new PHPExcel();
// Set properties
$objPHPExcel->setActiveSheetIndex(0);
$objPHPExcel->getActiveSheet()->SetCellValue('A1', 'demo');//把demo寫入A1
$objPHPExcel->getActiveSheet()->SetCellValue('A2', 'demo2');//把demo2寫入A2
$objPHPExcel->getActiveSheet()->getStyle('A2')->getFont()->setBold(true);//加粗A2
//
$objWriter = new PHPExcel_Writer_Excel5($objPHPExcel);
$objWriter->save('php://output');//輸出到瀏覽器excel
注意:若是沒有作第2步,會出現異常錯誤ip
Discuz! System Error Oops! System file lost: class/phpexcel/phpexcel_shared_zipstreamwrapper.phpget