本例测试中用的是ucenter x2.0和phpExcel v1.7.7
1.将解压的phpExcel文件放入到source/class下,并将phpExcel.php文件重新命名为class_phpexcel.php
2.注释掉source/class/class_core.php文件中import函数中抛出异常的那一行
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');//输出到浏览器
注意:如果没有做第2步,会出现异常错误
Discuz! System Error Oops! System file lost: class/phpexcel/phpexcel_shared_zipstreamwrapper.php