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

ASP.NET MVC: How to call actions in one batch?


In ASP.NET MVC, by default, we call actions which return JsonResult in separate HTTP AJAX requests.

How to Listen for JCombobox Selection Event

java swing event-handling jcombobox jpopup

When I select the JCombobox I want to handle an event when its selected and the dropdown is shown as well as handle the event when the drop down disappears and the JCombobox is de-selected.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.