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 ;

You are exporting a tab separated file, there is no way to add excel formatting to it. Something like this may do the trick: http://phpexcel.codeplex.com/

Give some basic ideas regarding this.

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 .

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

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

I can't make it any simpler than the Hello World example on their website.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.