我的主要代码如下:
public function echoExecl(){
error_reporting(E_ALL);
Vendor('PhpExcel.PHPExcel');
Vendor('PhpExcel.PHPExcel.IOFactory');
Vendor('PhpExcel.PHPExcel.Writer.Excel5');
Vendor('PhpExcel.PHPExcel.Writer.PDF');
$objPHPExcel = new PHPExcel();
...........
$m_exportType = "pdf";
// 如果需要输出EXCEL格式
if($m_exportType=="excel"){
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
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/vnd.ms-excel;");
header("Content-Type:application/octet-stream");
header("Content-Type:application/download");
$fileName = "库存统计_" . $_SESSION["user_name"] . "_" . date('Ymd') . ".xls";
header("Content-Disposition:attachment;filename=".$fileName);
header("Content-Transfer-Encoding:binary");
$objWriter->save("php://output");
}
// 如果需要输出PDF格式
if($m_exportType=="pdf"){
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'PDF');
$objWriter->setSheetIndex(0);
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/pdf");
header("Content-Type:application/octet-stream");
header("Content-Type:application/download");
$fileName = "库存统计_" . $_SESSION["user_name"] . "_" . date('Ymd') . ".pdf";
header("Content-Disposition:attachment;filename=".$fileName);
header("Content-Transfer-Encoding:binary");
$objWriter->save("php://output");
}
exit;
}
这样的话报错:
PDF Rendering library has not been defined.
如果引入:
Vendor('PhpExcel.PHPExcel.Writer.PDF.DomPDF');
又报报错:
Unable to load PDF Rendering library
请问这个怎么处理?
最佳答案