Salut, j'ai besoin de faire des header apres des echo pour generer un fichier excel mais il me donne l'erreur comme quoi le hearder est deja envoye, je pensais que ca posait pas de probleme grace au flush mais non... comment faire SVP ?

Code PHP : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
if (ob_get_level() == 0) ob_start();
echo 'test1';
ob_flush();
flush();
sleep(3);
echo 'test2';
ob_flush();
flush();
ob_end_flush();
 
require 'phptoexcel/PHPExcel.php';
$objPHPExcel = new PHPExcel();
/** You can set many properties */
$objPHPExcel->getProperties()->setCreator("My company")
             ->setLastModifiedBy("John Doe")
             ->setTitle("Annual report")
             ->setSubject("Sales")
             ->setDescription("Annual sales report by John Doe")
             ->setCategory("Finance");
 
/** Choose one of sheets */
$activeSheet = $objPHPExcel->setActiveSheetIndex(0);
/** Simply set value of cell */
$activeSheet->setCellValue("A1", 'plural');
// Redirect output to a client’s web browser (Excel5)
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="01simple.xls"');
header('Cache-Control: max-age=0');
// If you're serving to IE 9, then the following may be needed
header('Cache-Control: max-age=1');
// If you're serving to IE over SSL, then the following may be needed
//header ('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
header ('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); // always modified
header ('Cache-Control: cache, must-revalidate'); // HTTP/1.1
header ('Pragma: public'); // HTTP/1.0
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save('php://output');
exit;
?>