1 pièce(s) jointe(s)
telecharger un fichier excel issu d'une base mysql
Bonjour,
dans un script php je génère un fichier excel que je télécharge su mon PC. a l'ouverture de ce fichier excel j'obtiens le message suivant:Pièce jointe 235964
Voici mon script:
Code:
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
| <?php
.../..
header("Content-type: application/vnd.ms-excel;charset=utf-8");
header("Content-Disposition: attachment; filename=catalogue.xls");
$db=mysql_connect(DB_HOST, DB_USER, DB_PASS) or die(mysql_error());
mysql_select_db(DB_NAME) or die(mysql_error());
$query_produits ="SELECT *from catalogue ORDER BY Supplier";
$rsl=mysql_query($query_produits) or die(mysql_error());;
// $row_produits = mysql_fetch_assoc($rsl);
$compte= mysql_num_rows($rsl);
$tbl= " <html><body><table border='1' cellpadding='0' cellspacing='0'>
<tr bgcolor:'white' height='40px'>
</tr>
<tr>
<td align='center' colspan='2'><b>LISTE DES PRODUITS</b></td>
</tr>
<tr height='40px'>
<td bgcolor='#CCCCCC' align center>Fourniseur</td>
<td bgcolor='#CCCCCC' align center>Produit</td>
</tr>";
while ($data = mysql_fetch_array($rsl))
{
$tbl = $tbl . "<tr>";
$tbl = $tbl . "<td>" . $data['Supplier'] . "</td>";
$tbl = $tbl . "<td>" . $data['prod_name'] . "</td>";
$tbl = $tbl . "</tr>";
}
$tbl = $tbl . "</table></body></html>";
print $tbl ;
?> |
Je ne souhaite pas utiliser la suite PHPEXCEL qui semble apporter des solutions.
Merci d'avance pour toute idée.
JD