I tried the following code, and exited before the first header - it gives me a blank page (no output).
error_reporting(E_ALL);
ini_set('display.errors', 1);
-- Yes teynon, i'm using:
$objWriter->save("phpCOLONSLASHSLASHoutput");
But you say that i have to remove it because it wipes out the line? -- I commented out the headers and the result is corrupted data printed to the web broswer: (I shortened the entire output)
ÐÏࡱá;þÿ þÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ Ààõÿ Ààõÿ Ààõÿ Ààõÿ Ààõÿ Ààõÿ Ààõÿ Àà ÀàÈàÈàÈà ÈàÈàÈàÈàÌàÌàÀàÈàÈàÈàÈàèàÈàèà¤ìà%ìà¥ìàèàèàèà¥ìà%ìà¦ÌàÈà§ìà¦Ìà§ìà§ìŠà§ìŠàè‹àè‹à Èà ÈàÈàØàÈàÈàÀàè‹àè‹àè‹àȉàÈàÈà Ø“€ÿ’â8ÿÿÿîì᥶Êÿÿ}$ }ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
-- And finally I added the :
require_once 'PHPExcel/PHPExcel.php';
And i'm getting the same corrupted data as i posted above. -- This is my entire code:
// processing form submitted //
if (!isset($_POST['btnSubmit'])) exit;
error_reporting(E_ALL);
ini_set('display.errors', 1);
//include PHPExcel library//
require_once "Classes/PHPExcel/IOFactory.php";
require_once "Classes/PHPExcel.php";
// Load Files //
$objTpl = PHPExcel_IOFactory::load("template.xlsx");
$objTpl->setActiveSheetIndex(); //set first sheet as active
$objTpl2 = PHPExcel_IOFactory::load("file.xls");
// Set the Cells with values //
$objTpl->getActiveSheet()->getStyle('C2')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT); //C1 is right-justified
$objTpl->getActiveSheet()->setCellValue('F3', date('Y-m-d')); //set C1 to current date
$objTpl->getActiveSheet()->getStyle('C4')->getAlignment()->setWrapText(true); //set wrapped for some long text message
$objTpl->getActiveSheet()->getColumnDimension('C')->setWidth(40); //set column C width
$objTpl->getActiveSheet()->getRowDimension('4')->setRowHeight(120); //set row 4 height
$objTpl->getActiveSheet()->getStyle('A4:C4')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_TOP); //A4 until C4 is vertically top-aligned
$objTpl->getActiveSheet()->setCellValue('D3', $objTpl2->getActiveSheet(1)->GetCell('B1')->getValue());
$objTpl->getActiveSheet()->setCellValue('B1',$objTpl2->getActiveSheet()->GetCell('B1')->getValue());
// Prepare Download //
$filename='goodFile.xlsx'; //Sets the Filename
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="'.$filename.'"');
header('Cache-Control: max-age=0');
$objWriter = PHPExcel_IOFactory::createWriter($objTpl, 'Excel5');
$objWriter->save("phpCOLONSLASHSLASHoutput");
exit; //done.. exiting!