[trick] Membuat Report Excel Tanpa Library dengan php dan mysql

Ok Trik Kali ini yaitu membuat report excel tanpa pake library >>

langsung saja >>

data

<?php
mysql_connect(“localhost”,”root”,””);
mysql_select_db(“latihan”);

$sql=mysql_query(“select * from member”);

$content=”
<table border=1 cellpadding=4 cellspacing=0 style=’border-collapse:collspase;’>
<tr>
<td>Id</td>
<td>Nama</td>
<td>Email</td>
<td>Pesan</td>
</tr>
“;

while($data=mysql_fetch_array($sql)){

$content .=”
<tr>
<td>”.$data[‘id’].”</td>
<td>”.$data[‘nama’].”</td>
<td>”.$data[’email’].”</td>
<td>”.$data[‘pesan’].”</td>
</tr>
“;
}
$content .=”</table>”;

header(“Content-type: application/msdownload”);

header(“Content-disposition: inline; filename=laporan.xls”);

header(“Content-length: ” . strlen($content));

echo $content;

?>

untuk hasilnya anda bisa lihat langsung dalam file xls..

kopi pasti aja kodingnya dan buat databasenya, anda akan bisa lihat hasilnya.

Leave a comment

3 Comments

  1. valdi

     /  10/09/2013

    tengkyu sudah berbagi ilmu😀 #yeah

    Reply
  1. [trick] Membuat Report Excel Tanpa Library dengan php dan mysql | Zainal Fanani

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 )

Google+ photo

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

Connecting to %s

%d bloggers like this: