0

hi
this is a code for export to excel.
I want to color the headers light blue and all result of query like one white then one grey and repeat.

session_start();

 $a= $_GET["id"];

  function cleanData(&$str)
  {
    $str = preg_replace("/\t/", "\\t", $str);
    $str = preg_replace("/\r?\n/", "\\n", $str);
  }

  # file name for download
  $filename = "EIMS_Finance" . date('Y-m-d') . ".xls";

header("Content-Disposition: attachment; filename=\"$filename\"");
 header("Content-Type:application/vnd.ms-excel");

  $flag = false;


          
          $qry1=mysql_query("(SELECT * from Table where Id=$a");

			while(false !== ($r1=mysql_fetch_assoc($qry1)))
		     
			{
			     
			 
                  if(!$flag) {
				  # display field/column names as first row
				   echo implode("\t", array_keys($r1)) . "\n";
				  $flag = true;
				      }
				 
				   array_walk($r1, 'cleanData');
                   echo implode("\t", array_values($r1))."\n" ;
	     
		

               }



?>
GINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
3
Contributors
8
Replies
12
Views
7 Years
Discussion Span
Last Post by pritaeas
0

For these you have to visit the websites and look for all the demos then only you can understand easily other wise you have learn the tutorials regarding the export excel .

0

Can you look in my code and can I change the whole code according to PHPEXCEL?

0

yea I look but its seems very difficult to me. can you guide me with simple and easy example

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.