Export into Excel

 Exporting data into excel from PHP can done easily without including the Excel classes by using the header command as seen below. Here is the code will show you simple export in excel,

                                                                                                                                                                   

 

 

 

 

 

 

 

 

 

 

 

 

 

header(“Content-type: application/vnd.ms-excel”);
  header(“Content-Disposition: attachment; ame=Report.xls/Report.csv”);
  $STATUS = array(‘Blocked/Inactive’, ‘Active’);
 
  echo “<table width=’100%’  border=’0′ cellpadding=’0′ cellspacing=’0′><thead>”;
  echo “<tr><td>ID</td><td>Email Address</td><td>URL</td></tr></thead>”;
  while($row = mysql_fetch_assoc($result))
  {
   echo “<tr><td>”.$row['id'].”</td><td>”.$row['email'].”</td><td>”.$row['url'].”</td></tr>”;
     
  }
  echo “</tbody></table>”;

About these ads

2 Comments

  1. younten said,

    June 13, 2009 at 6:50 am

    nice one… i have been looking for such kind of tutorial

    • rafeekphp said,

      June 16, 2009 at 11:08 am

      Hi Younten,
      Thanks :)

      Rafeek


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: