I'm able to download data from a database as a .xls file thanks to a nice tutorial here , the essence of which is using headers:


header("Content-Type: application/vnd.ms-excel");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");


/* And to give the user that "open or save" dialog box, simply add the line between the PHP tags: */

header("content-disposition: attachment;filename=yourFileName.xls");


If I try to run the page as a cronjob, I only get the data on the page (ie. a table of html) - I would like to get the .xls as an email attachment.

Anyone know of a way to get the data emailed as an attachment with a cronjob or is there a better way of approaching this?

    thanx for the advice.

    My ISP [ when I do phpinfo() ] only mentions '--with-pear' in the 'Configure Command' - dunno if that even means it's installed and I certainly won't be able to install pear on their server.
    Is this the only way?

      if they have pair you just download that package and you can run it as a class. im working on a general php mime mailer class now, i still have some testing to do at this point though.

        Write a Reply...