我正在使用 PHPExcel 以 Excel 和 CSV 格式导出 MySQL 查询结果,但我无法执行相同操作并将结果导出为 PDF。
下面是我用来执行此操作的代码:
$objPHPExcel = new PHPExcel;
$headings = array('ID','Source Date','Source','Programme Name','Coder','Presenter','Format','Audio Path','Video Path');
$rowNumber = 1;
$col = 'A';
foreach($headings as $heading)
{
$objPHPExcel->getActiveSheet()->setCellValue($col.$rowNumber,$heading);
$col++;
}
$rowNumber = 2;
while($row = $dbase->fetchrow($query))
{
$col = 'A';
foreach ($row as $cell) {
$objPHPExcel->getActiveSheet()->setCellValue($col.$rowNumber,$cell);
$col++;
}
$rowNumber++;
}
//freeze pane so that the heading does not scroll
$objPHPExcel->getActiveSheet()->freezePane('A2');
//save as an Excel(.xls) file
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel,'PDF');
$objWriter->writeAllSheets();
$objWriter->save('Report.pdf');
exit();
我做错了什么?
提前致谢