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. Link to comment https://forums.phpfreaks.com/topic/29817-post-data-dumped-to-excel/ 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. Link to comment https://forums.phpfreaks.com/topic/29817-post-data-dumped-to-excel/#findComment-136915 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] Link to comment https://forums.phpfreaks.com/topic/29817-post-data-dumped-to-excel/#findComment-136928 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? Link to comment https://forums.phpfreaks.com/topic/29817-post-data-dumped-to-excel/#findComment-136942 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? Link to comment https://forums.phpfreaks.com/topic/29817-post-data-dumped-to-excel/#findComment-136948 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. Link to comment https://forums.phpfreaks.com/topic/29817-post-data-dumped-to-excel/#findComment-136954 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.