Page 1 of 1

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

Posted: Thu Oct 26, 2006 8:13 pm
by cloud_0085
Now i had generated a report, but i want to export as excel format.
Anyone can teach me?
thanks :D

Posted: Thu Oct 26, 2006 8:51 pm
by feyd

Posted: Fri Oct 27, 2006 12:15 am
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;

Posted: Fri Oct 27, 2006 2:00 am
by cloud_0085
urgh...
how to call query from the function??[/quote]

Posted: Fri Oct 27, 2006 2:19 am
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

                }

Posted: Fri Oct 27, 2006 5:35 pm
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.