DeepakJ Posted July 30, 2007 Share Posted July 30, 2007 I want to make a table with all of my MySQL data in excel but am not quite sure about how to do it. Essentially, there will be a button on a form that you click and then excel will popup with all the information in there. Help would be greatly appreciated. Quote Link to comment Share on other sites More sharing options...
trq Posted July 30, 2007 Share Posted July 30, 2007 Assuming your on windows you can use php's COM extension to connect to the underlying excell application object. Quote Link to comment Share on other sites More sharing options...
DeepakJ Posted July 30, 2007 Author Share Posted July 30, 2007 Anything special I would need to download? Is it very hard? Quote Link to comment Share on other sites More sharing options...
ss32 Posted July 30, 2007 Share Posted July 30, 2007 As long as you are using windows you should be fine. the only tough part about this is learning all of the specifications of the COM objects you are manipulating. Quote Link to comment Share on other sites More sharing options...
DeepakJ Posted July 30, 2007 Author Share Posted July 30, 2007 Ok what should I download to get COM working for Microsoft 2000 Small Business? Quote Link to comment Share on other sites More sharing options...
Barand Posted July 30, 2007 Share Posted July 30, 2007 another way is SELECT a,b,a+b INTO OUTFILE "/tmp/result.csv" FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY "\n" FROM mytable and open the csv in excel Quote Link to comment Share on other sites More sharing options...
DeepakJ Posted July 30, 2007 Author Share Posted July 30, 2007 huh? could explain what each part of that does. I'm kinda new to php, started with it last thursday. Quote Link to comment Share on other sites More sharing options...
zq29 Posted July 30, 2007 Share Posted July 30, 2007 huh? could explain what each part of that does. I'm kinda new to php, started with it last thursday. 1. It's SQL, not PHP 2. It's pretty much written in English! Quote Link to comment Share on other sites More sharing options...
jscix Posted July 30, 2007 Share Posted July 30, 2007 Line 1. SELECT a,b,a+b INTO OUTFILE "/tmp/result.csv" ---> Selecting which data to process (Which Fields to collect information from) ---> Save collected data into result.csv (File) Line 2. FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' Line 3. LINES TERMINATED BY "\n" ---> I've never used these commands, But I assume they are for data parsing .. ---> Looks like it says: any text that may be enclosed in ' ', and seperated by , and \n signfying the end of a line. Line 4. FROM mytable ---> The Table which holds the feilds, you are collecting data from .. (See line1) Quote Link to comment Share on other sites More sharing options...
Barand Posted July 30, 2007 Share Posted July 30, 2007 If you want to go the COM route, see http://web.informbank.com/articles/technology/php-office-documents.htm Quote Link to comment Share on other sites More sharing options...
DeepakJ Posted July 30, 2007 Author Share Posted July 30, 2007 how would you do this with comma seperated values. I only wanna make the file. Not necessarily open it and all. Quote Link to comment Share on other sites More sharing options...
stemp Posted July 30, 2007 Share Posted July 30, 2007 Just try adding the header function and export your data as tab delimited. // The header is the most important part header('Content-type: application/ms-excel'); header('Content-Disposition: attachment; filename=FILENAME.xls'); // after connecting to your DB $rows = mysql_fetch_row($result); // Return your result as tab delimited echo $rows[0]."\t"; echo $rows[1]."\t"; echo $rows[2]."\t"; echo $rows[3]."\t"; echo $rows[4]; Quote Link to comment Share on other sites More sharing options...
DeepakJ Posted July 30, 2007 Author Share Posted July 30, 2007 Does anyone know a good website that teaches how to do this? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.