PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > alt.php > problem saving an excel file
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
problem saving an excel file

Réponse
 
LinkBack Outils de la discussion
Vieux 09/09/2007, 17h12   #1
GD
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut problem saving an excel file

i have a php script to convert a simple query into an excel format
file (tab delimited) which is called mysql-to-excel. on the author's
website when i click on the script i download an xls file, but when i
do the same on my server it just echos back the query without saving a
file. any ideas. here is the script:

<?php
include 'config.php';
include 'opendb.php';

$query = "SELECT * FROM information ORDER BY lastname";
$result = mysql_query($query) or die('Error, query failed');

$tsv = array();
$html = array();
while($row = mysql_fetch_array($result, MYSQL_NUM))
{
$tsv[] = implode("\t", $row);
$html[] = "<tr><td>" .implode("</td><td>", $row) . "</td></tr>";
}

$tsv = implode("\r\n", $tsv);
$html = "<table>" . implode("\r\n", $html) . "</table>";

$fileName = 'mysql-to-excel.xls';
header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=$fileName");

echo $tsv;
//echo $html;

include 'closedb.php';
?>


thank you very much,
GD

  Réponse avec citation
Vieux 09/09/2007, 17h22   #2
J.O. Aho
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: problem saving an excel file

GD wrote:
> i have a php script to convert a simple query into an excel format
> file (tab delimited) which is called mysql-to-excel. on the author's
> website when i click on the script i download an xls file, but when i
> do the same on my server it just echos back the query without saving a
> file. any ideas. here is the script:


This has much to do with mimetypes and how things are configured, by tradition
products from microsoft are quite bad when it comes to mimetypes. I suggest
you try with application/octet-stream which seems to be the one and only way
to force a microsoft product to always save a file instead of displaying them.


--

//Aho
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 05h59.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,06986 seconds with 10 queries