getActiveSheet()->setShowGridLines(false); echo date('H:i:s') , " Set orientation to landscape" , PHP_EOL; $objPHPExcel->getActiveSheet()->getPageSetup()->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE); echo date('H:i:s') , " Write to PDF format using {$rendererName}" , PHP_EOL; if (!PHPExcel_Settings::setPdfRenderer( $rendererName, $rendererLibraryPath )) { die( 'NOTICE: Please set the $rendererName and $rendererLibraryPath values' . PHP_EOL . 'at the top of this script as appropriate for your directory structure' ); } $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'PDF'); $objWriter->setSheetIndex(0); $objWriter->save(str_replace('.php', '_'.$rendererName.'.pdf', __FILE__)); echo date('H:i:s') , " File written to " , str_replace('.php', '_'.$rendererName.'.pdf', __FILE__) , PHP_EOL; // Echo memory peak usage echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , PHP_EOL; // Echo done echo date('H:i:s') , " Done writing files" , PHP_EOL;