I want to write a reference xls file and retrieve the result. When I tested with a single file, it works but when the reference file is complex, this returns me a corrupt file with with kinds of data:
Which is at the beginning like this:
My php file is:
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
date_default_timezone_set('Europe/London');
if (PHP_SAPI == 'cli')
die('This example should only be run from a Web Browser');
/** Include PHPExcel */
require_once '../phpexcel/Classes/PHPExcel.php';
$objPHPexcel = PHPExcel_IOFactory::load('../upload/ref/fileref.xls');
$objWorksheet = $objPHPexcel->getActiveSheet();
$objWorksheet = $objPHPexcel->getActiveSheet();
$objWorksheet->getCell('B1')->setValue('toto');
$objWorksheet->getCell('B3')->setValue('toto');
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="newfiletodownload.xls"');;
header('Cache-Control: max-age=0');
header('Cache-Control: max-age=1');
header ('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header ('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header ('Cache-Control: cache, must-revalidate');
header ('Pragma: public');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPexcel, 'Excel5');
$objWriter->save('php://output');
Do you have solution ? Thanks, Neyoh