[nycphp-talk] Fw: PHP form to MS Excel file
Mitch Pirtle
mitch.pirtle at gmail.com
Wed Sep 8 12:32:49 EDT 2004
Hey there,
One option for you is to put your form submits into a database, and
then output the whole results in a CSV file - but instruct the browser
to use Excel to open it up.
ADOdb has a native facility to output a query as a CSV file:
http://adodb.sf.net
Then you fool the browser into thinking it is downloading an Excel
file with the following headers commands:
header('Pragma: public');
header('Last-Modified: '.gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate'); // HTTP/1.1
header('Cache-Control: pre-check=0, post-check=0, max-age=0'); // HTTP/1.1
header('Content-Transfer-Encoding: none');
header('Content-Type: application/octet-stream; name="basedata.csv');
//This should work for Non IE/Opera browsers
header('Content-Type: application/octetstream; name="basedata.csv');
// This should work for IE & Opera
header('Content-Disposition: inline; filename="basedata.csv');
'basedata.csv' is the bogus filename I pass just so it looks like a
real file, and so your manager will have a simple filename to save as.
If there is enough interest I can provide an example class that does just this.
-- Mitch, frantically trying to get Mambo 4.5.1 final out the door :-D
More information about the talk
mailing list