help me: how to export the form to the excel format???

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
cloud_0085
Forum Newbie
Posts: 4
Joined: Sun Apr 16, 2006 8:48 pm

help me: how to export the form to the excel format???

Post by cloud_0085 »

Now i had generated a report, but i want to export as excel format.
Anyone can teach me?
thanks :D
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

angelena
Forum Commoner
Posts: 53
Joined: Mon Nov 22, 2004 4:10 am

Post by angelena »

Try this small part of code see if it can help u

Code: Select all

$reportName="report";
               $filetype="csv";
               $varInput="....whatever value u want to pass in..";

                $ip = $_SERVER['SERVER_NAME'];
	
                header("Content-type: application/octet-stream"); 
	header("Pragma: public"); 
	header("Content-disposition: attachment; filename=".$ip."_".$reportName."_".date("Ymd").".".$filetype); 
	header("Cache-Control: post-check=0, pre-check=0, max-age=0");
	header("Expires: 0"); 
	
	$current_datetime			=	date("F j, Y, g:i a");
   
	
	...some function to call your report query
	print "\n";
			
	print $head."\n".$data;
cloud_0085
Forum Newbie
Posts: 4
Joined: Sun Apr 16, 2006 8:48 pm

Post by cloud_0085 »

urgh...
how to call query from the function??[/quote]
angelena
Forum Commoner
Posts: 53
Joined: Mon Nov 22, 2004 4:10 am

Post by angelena »

Code: Select all

$reportName="report"; 
               $filetype="csv"; 
               $varInput="....whatever value u want to pass in.."; 

                $ip = $_SERVER['SERVER_NAME']; 
        
                header("Content-type: application/octet-stream"); 
        header("Pragma: public"); 
        header("Content-disposition: attachment; filename=".$ip."_".$reportName."_".date("Ymd").".".$filetype); 
        header("Cache-Control: post-check=0, pre-check=0, max-age=0"); 
        header("Expires: 0"); 
        
        $current_datetime                     =      date("F j, Y, g:i a"); 
    
        
        $this->get_query(...variable to pass in...);                               
        print $head."\n".$data;


              function get_query(...variable to pass in....)
	{

                ....sql scripts goes here

                }
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

cloud_0085 wrote:urgh...
how to call query from the function??
You call the queries you need first, the assign the result into a var/array, then assign the var/array into the output of the Excel writer.
Post Reply