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 41 42 43 44 45 46 47 48 49 50 51 52
| public function executeExcel(sfWebRequest $request)
{ //$y=$request->getParameter($t);
//$this->taba=array_merge($this->taba,$this->patients );
$file= fopen(sfConfig::get('sf_upload_dir')."/excel.xls", "w") or die ("can't open file.");
$ms= " <table border='1'> <tr>";
$i=0;
foreach ($this->taba as $v) { $i++;
$ms=$ms."<td>". $v."</td>";
}
$ms=$ms." </tr></table> ";
$tr=" <table border='1'>
<tr>
<td colspan='4'>Customer </td>
<td>N° de facture :</td>
</tr>
<tr>
<td colspan='4'>Project :</td>
<td>Date sent :</td>
</tr>
<tr>
<td colspan='4'>Net cash:</td>
<td>Deadline : </td>
</tr>
<tr>
<td colspan='4'></td>
<td>Deadline :</td>
</tr>
<tr>
<td>
</td>
</tr>";
fwrite($file,$ms) or die ("can't write to file.");
$f="/excel.xls" ;
session_write_close();
$this->getResponse()->clearHttpHeaders();
$this->getResponse()->setContentType('application/force-download');
$this->getResponse()->setHttpHeader('Content-Disposition', 'attachment; filename="' .$f.'"');
$this->getResponse()->setHttpHeader('Content-Transfer-Encoding', 'binary');
$this->getResponse()->setHttpHeader('Content-Length', $f);
$this->getResponse()->setHttpHeader('Connection', 'close');
$this->getResponse()->sendHttpHeaders();
readfile(sfConfig::get('sf_upload_dir') ."/excel.xls");
throw new sfStopException();
$this->redirect("prostate_recap/filtre");
} |
Partager