Formatting Issues with PDF vs XLSX Output

Topics: User Forum
Jul 29, 2008 at 3:13 PM
Edited Jul 29, 2008 at 3:20 PM
I've created a spreadsheet which outputs perfectly and keeps within the print margins of the page. I also want to be able to output to PDF as well, so I've got a simple switch at the bottom of the page stating:
if ($_GET['file_format'] == 'pdf') {
// Save PDF file
$objWriter = new PHPExcel_Writer_PDF($objPHPExcel);
$objWriter->save(str_replace('.php', '.pdf', __FILE__));

// Rename and Move File
rename( 'agent_statement.pdf', '../archive/'.$new_filename.'.pdf' );
} else {
// Save Excel 2007 file
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));

// Rename nad Move File
rename( 'agent_statement.xlsx', '../archive/'.$new_filename.'.xlsx' );
It creates the PDF, but the formatting is all wrong. Images are missing, row heights and widths are incorrect, information off the side of the pages, etc. Is there something I am doing wrong, or do I need to have a page styled for PDF and another for XLSX?

Jul 29, 2008 at 4:45 PM
Edited Jul 29, 2008 at 4:46 PM
I have run into some trouble as well with the PDF writer as well so I recently addressed the issues here:

The problems arise especially when you have multi-line text in cells. Maybe you have a similar situation. There is a chance that you can get around the problems by setting explicit heights for the problematic cells, but I'm not sure.