Link to home
Start Free TrialLog in
Avatar of mapenn
mapenn

asked on

How to auto-create and save spreadsheet document on server.

I am writing a PHP script that pulls data from a MySQL table and converts it into an Excel spreadsheet. This process functions correctly -- I can output it as a downloadable file to the user's browser.

Now, the final step is what I am having trouble with. Instead of outputting the the browser, this script needs to SAVE the data as an excel file on the web server. The script will be run nightly as a cron job.

I am attaching a code snippet that shows how I am combining the headers and the data ($data) for the output.

Instead of outputting to the browser, how can I output to a saved file on the server? Thanks!
header("Content-type: application/xls");
header("Content-Disposition: attachment; filename=Beta_Product_Master_Table.xls");
header("Pragma: no-cache");
header("Expires: 0");
echo $header."\n".$data;s

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Mahdii7
Mahdii7
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mapenn
mapenn

ASKER

Perfect. Thank You so much!
Avatar of mapenn

ASKER

Thanks it helps a lot