...

View Full Version : Export mySQL to Excel in scheduled email



rayd
02-10-2005, 12:53 AM
I have a PHP script that queries mySQL DB and coverts result into tab delimited, then the user can open http://xyz.com/report.php and will get prompted to open/save the Excel.

My user now needs me to generated this report on a scheduled interval ( e.g., every 10 minutes) and then have it emailed to them. This is on a hosted server.

I tried to use crontab:
1. I first tried wget: wget -O test.xls http://www.xyz.com/report.php
but got some kind of permission denied error, I searched the web and this might have something to do with not been able to write to somewhere...(linux thing)

2. I then tried lynx -dump http://www.xyz.com/report.php this worked! but I just get an email with tab delimited data in plain format, not Excel.

3. I have thought about using Spreadsheet::WriteExcel in perl or the PEAR version, but that will take a lot more work and I might have to ask the hosting company to install stuff again...

Do you have any comments on what I am trying to do? Am I doing something wrong? Am I missing something simpler?

I had to ask the host to enable crontab and wget already, on one hand I don't want to keep asking them for stuff and can't get it to work, on the other hand this looks like a pretty lame installation to began with...It seems to be a very basic/limited hosting plan)

Thank you.

rayd
02-11-2005, 05:24 PM
I figured it out.

1. Schedule crontab to run this regularly
2. Pulled the data from DB, dumped it into an Excel using PEAR library Spreadsheet_Excel_Writer.
3. Emailed it to client using phpmail

PM me if you like to know more.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum