Page 1 of 1

how can i view data in the excel sheet

Posted: Mon Feb 16, 2004 12:57 am
by softsolvers
hello friends i want to view my data in the excell sheet which will be fetched by the mysql.could you help me

Plz help on this matter

Posted: Mon Feb 16, 2004 5:58 am
by softsolvers
hello friends,
i want to view the data fetched from the mysql data base o the excel sheet can u suggest me that what should i do.

Posted: Mon Feb 16, 2004 8:29 am
by AVATAr

Posted: Mon Feb 16, 2004 5:24 pm
by DuFF
And once you have the MySQL stuff down:
http://builder.com.com/5100-31-5077752.html
Suppose you're running an intranet Web site that has data stored in Microsoft SQL Server, and your users need that data in Excel format. You can have PHP run the necessary SQL queries and format the output, then use COM to open Excel, dump the data stream into it, and save the file on the user's desktop.

Posted: Mon Feb 16, 2004 6:09 pm
by Dr Evil
- Make a page that fetches all the data by line in CSV format.
- dont forget to add the right header :

Here is a code I wrote a moment ago (in French) PHP:

Code: Select all

<?php

header("Content-type: application/octet-stream"); 
header("Content-Disposition: attachment; filename=table.csv"); 
header("Content-Transfer-Encoding: binary"); 

include ("Connections/localhost.php"); //contains all connection params 

$connection = mysql_connect ("$hostname_localhost", "$username_localhost", "$password_localhost"); 
   $query = "SELECT * FROM sirca_concours"; 
   $result= mysql_db_query ("$database_localhost", $query); 
   $numOfRows = mysql_num_rows($result); 

for ($i = 0; $i < $numOfRows; $i++){ 
   $civilite    = mysql_result ($result, $i, civilite); 
   $prenom      = mysql_result ($result, $i, prenom); 
   $nom      = mysql_result ($result, $i, nom); 
   $adresse1    = mysql_result ($result, $i, adresse1); 
   $adresse2   = mysql_result ($result, $i, adresse2); 
   $ville      = mysql_result ($result, $i, ville); 
   $npa      = mysql_result ($result, $i, npa); 
   $pays      = mysql_result ($result, $i, pays); 
   $email      = mysql_result ($result, $i, email); 

print ""$civilite","$prenom","$nom","$adresse1","$adresse2","$ville","$npa","$pays","$email"\n"; 
} 
?>
Did I understand correctly ?

dispalying on excel sheety

Posted: Mon Feb 16, 2004 10:41 pm
by softsolvers
hello friends,
can you tell me what these header exactly stand for and what should be the actual code in that header if i am running code on local machine
looking f/w for result

Posted: Tue Feb 17, 2004 10:11 pm
by softsolvers
hello friends
can u help me it is urgent,plz. send me the snap shot of source code

Posted: Wed Feb 18, 2004 2:13 am
by Dr Evil
I don't quite get your question. These headers tell the browser that a csv document is being sent. So in fact the main page must simply link to this one. When the user clicks the link he'll get a" do you want to open or save?" box.
This works locally or on a remote machine.
If my answer is beside the point be more specific.


Evil

how can i take the drop down menu's value on the same page

Posted: Wed Feb 18, 2004 4:48 am
by softsolvers
hello friends
i want to take the value of the drop down menu on the same page means if user has selected his choice and the corresponding action has perform according to the selection.

Posted: Wed Feb 18, 2004 6:22 am
by softsolvers
thanks dr.
but problem is still the same,i.e. it is not displaying the excel sheet should i need to modify the php.ini file,i am using versio 4.3.4 is it make any difference.
plz. do help me

Posted: Wed Feb 18, 2004 7:29 am
by Dr Evil
I'm lost in your problem. The excel software is running locally on the user's PC/MAC so I do not see what the php.ini config has to do with this. Can you show me the page ?

Dr Evil

Posted: Wed Feb 18, 2004 8:00 am
by softsolvers
thanks dr.
actually i was not running it properly ,it is running well thanks very much
i will be very greatful if i would help u by any mean

An additional wrinkle...

Posted: Fri Feb 27, 2004 6:22 pm
by Sinemacula
I'm trying to do something similar, and I follow the script you've posted... but I've got another piece to what I'm trying which leaves me unsure how to proceed...

I want to be able to choose between several tables, which one I want to download as a csv file... (I've figured this part out, using a variable for the table name)... the catch is that each table has a different number of (and names of) fields, so I can't use the fieldnames to create the output. Is there a way to write the script so that it will figure that out on it's own?

Thanks,
Scott