Exporting PDF from MySQL query results using PHPExcel

I am using PHPExcel for exporting MySQL query results in Excel and CSV formats, but I have been unable to do the same and exporting the results as PDFs.

Below is the code Im using to do this:

$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)

$rowNumber = 2;
while($row = $dbase->fetchrow($query))
    $col = 'A';

    foreach ($row as $cell) {


//freeze pane so that the heading does not scroll

//save as an Excel(.xls) file
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel,'PDF');


What Im I doing wrong?

Thanks in Advance


If you're using the latest 1.7.8 version of PHPExcel, then you also need a PDF Rendering library (either tcPDF, DomPDF or mPDF) that you also need to install on your server. You then need to tell PHPExcel which of those libraries you're using, and where it's installed on your server.

This is described in section 6.9.1 of the Developer Documentation, entitled "PHPExcel_Writer_PDF"


You might also want to put some exception handling in your code.

Need Your Help

sqlnet bytes sent in timings on

oracle sqlplus

I ran an execution plan with AUTOTRACE TRACEONLY and TIMING ON but had a question about a few of things in there:

Running parallel in background

c# wpf background parallel-processing

Main question is: How to run the code within TestingButton_Click on several threads in background (similar to BackgroundWorker) so I will be able to: