Why the code export php file?

Topics: Developer Forum
Sep 1, 2014 at 10:11 AM
I don't know why the code will generate a php file not excel file?

Anyone can help me?

ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);

if (PHP_SAPI == 'cli')
    die('This example should only be run from a Web Browser');

/** Include PHPExcel */
require_once 'phpexcel_Classes/PHPExcel.php';

// Create new PHPExcel object
$objPHPExcel = new PHPExcel();

// Set document properties
$objPHPExcel->getProperties()->setCreator("non Ltd.")
                             ->setLastModifiedBy("non Ltd.")

// Rename sheet

// Set active sheet index to the first sheet, so Excel opens this as the first sheet

// Redirect output to a client’s web browser (Excel5)
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="p.xls"');
header('Cache-Control: max-age=0');

$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');

Sep 1, 2014 at 11:00 AM
Because the webserver isn't parsing PHP Files?