komquat Posted December 7, 2006 Share Posted December 7, 2006 Can I take information that I have from post data and dump it all to a Excell Spreadsheet? Any information on this would be greatly appreciated. Quote Link to comment Share on other sites More sharing options...
trq Posted December 7, 2006 Share Posted December 7, 2006 [quote]Can I take information that I have from post data and dump it all to a Excell Spreadsheet?[/quote]You could. You'll need the [url=http://php.net]COM[/url] interface. Quote Link to comment Share on other sites More sharing options...
bljepp69 Posted December 7, 2006 Share Posted December 7, 2006 You could easily write it to a "csv" file and then open that in Excel. This code should take all the POST variables and use the keys as the header row and put the values in the row beneath them. Haven't tested it though. Also, there is no error checking in this code.[code]<?phpforeach ($_POST as $key=>$val) { $$key = stripslashes($val); $header .= $key.","; $data .= $val.",";}$header = substr($header,-1)."\n"; //to strip away trailing comma and add a newline character$data = substr($data,-1);//to strip away trailing comma$filecontent = $header.$data; //merge the content$handle = fopen("yourfilehere.csv","w");fwrite($handle, $filecontent); // Write $filecontent to your opened file.fclose($handle);?>[/code] Quote Link to comment Share on other sites More sharing options...
komquat Posted December 7, 2006 Author Share Posted December 7, 2006 How do you determine where this file gets saved to, I would like to save it to my harddrive? Quote Link to comment Share on other sites More sharing options...
trq Posted December 7, 2006 Share Posted December 7, 2006 [quote]I would like to save it to my harddrive?[/quote]Do you mean download it? Quote Link to comment Share on other sites More sharing options...
bljepp69 Posted December 7, 2006 Share Posted December 7, 2006 Yeah, you'll have to write it to the server and then download the file. If you're doing all that, you might as well just echo the data to the screen and then copy-and-paste into Excel on your PC. Probably faster overall, and definitely less coding. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.