Bonjour,


j'ai cherché un peu partout. j'ai trouvé un script qui me permet à partir d'une requete sql de généré un fichier excel avec les données concerner.

Mon problème est le suivant :
- j'arrive à généré le fichier excel mais il me dit " impossible de lire le fichier"


Si quelqu'un à une idée , je suis preneuse Smile

Voici le code pour génér mon fichier excel :

Code : 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
 
<?php
  //header("Content-Type: application/vnd.ms-excel");
  header("Content-Type: application/csv-tab-delimited-table");
  header("Expires: 0");
  header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  header("content-disposition: attachment;filename=listing_client.csv");
  $text = "<table border=1>";
  $text .= "<tr>
  <th><h3> NomSociete </th>
  <th><h3> Téléphone </th>
  <th><h3> Login </th>
  <th><h3> Mot de Passe </th></tr>";
  $con = connect( DB_SERVER , DB_USER, DB_PW, DB );
  $req_sql = " SELECT nomSociete, telFixe, login, mdp FROM `interlocuteur` WHERE 1 ;";
  $sql = @odbc_exec($con, $req_sql); 
  //echo "test odbc_exec".@odbc_exec($req_sql);
  $color = "#c0ffe0";
    while(odbc_fetch_row($sql)){
    if($color=="#e0ffff"){$color = "#c0ffe0";}else{$color = "#e0ffff";}
 
      $text .= "<TR>";
      $text .= "<TD><h5>".odbc_result($sql, 1)."</TD>";
      $text .= "<TD><h5>".odbc_result($sql, 2)."</TD>";
      $text .= "<TD><h5>".odbc_result($sql, 3)."</TD>";
      $text .= "<TD><h5>".odbc_result($sql, 4)."</TD>";
      $text .= "</TR>";
 
  }
  $text .="</table>";
  echo $text;
?>
Merci d'avance

jenny