load("templates/26template.xlsx"); /** at this point, we could do some manipulations with the template, but we skip this step */ // Export to Excel2007 (.xlsx) echo date('H:i:s') . " Write to Excel5 format\n"; $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); $objWriter->save(str_replace('.php', '.xlsx', __FILE__)); // Export to Excel5 (.xls) echo date('H:i:s') . " Write to Excel5 format\n"; $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); $objWriter->save(str_replace('.php', '.xls', __FILE__)); // Export to HTML (.html) echo date('H:i:s') . " Write to HTML format\n"; $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'HTML'); $objWriter->save(str_replace('.php', '.htm', __FILE__)); // Export to PDF (.pdf) echo date('H:i:s') . " Write to PDF format\n"; $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'PDF'); $objWriter->save(str_replace('.php', '.pdf', __FILE__)); // Remove first two rows with field headers before exporting to CSV echo date('H:i:s') . " Removing first two rows\n"; $objWorksheet = $objPHPExcel->getActiveSheet(); $objWorksheet->removeRow(1, 2); // Export to CSV (.csv) echo date('H:i:s') . " Write to CSV format\n"; $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'CSV'); $objWriter->save(str_replace('.php', '.csv', __FILE__)); // Export to CSV with BOM (.csv) echo date('H:i:s') . " Write to CSV format (with BOM)\n"; $objWriter->setUseBOM(true); $objWriter->save(str_replace('.php', '-bom.csv', __FILE__)); // Echo memory peak usage echo date('H:i:s') . " Peak memory usage: " . (memory_get_peak_usage(true) / 1024 / 1024) . " MB\r\n"; // Echo done echo date('H:i:s') . " Done writing files.\r\n";