Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Feb 2005
    Location
    Colorado
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Export mySQL to Excel in scheduled email

    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.

  • #2
    New to the CF scene
    Join Date
    Feb 2005
    Location
    Colorado
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cool

    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •