Excel dosyası oluşturma

Konu sahibi son olarak 2618 gün önce görüldü
Excel dosyası oluşturma
Eğer sitenizde bir excel tablosu oluşturup bunu kullanıcıya dosya olarak göndermek istiyorsanız buyrun

<?
/*
*********************************
XLS uzantılı dosya oluşturmaya yarayan class
nette 3 saatlik bir turdan sonra yazdığım bu class
isteyen herkese açıktır Kodları istediğiniz gibi değiştirebilirsiniz
hüseyin YILDIRIM
*********************************
*/
class xlsolustur {
var $xls_data = "";
var $xls_dosya = "ornek";
function basla()
{
$this->xls_data = pack( str_repeat('s', 6), 0x809, 0x8, 0x0, 0x10, 0x0, 0x0 );
}

function bitir()
{
$this->xls_data= pack( str_repeat('s', 2), 0x0A, 0x00 );
return;
}

function hucre($row, $col, $val)
{
if (is_float($val) || is_int($val))
{
$this->xls_data = pack(str_repeat('s', 5), 0x203, 14, $row, $col, 0x0);
$this->xls_data = pack("d", $val);
}
else
{
$l = strlen($val);
$this->xls_data = pack(str_repeat('s', 6), 0x204, 8 + $l, $row, $col, 0x0, $l);
$this->xls_data = $val;
}
}

function gonder()
{
$this->bitir();
header("Content-type: application/x-msexcel");
header("Content-Disposition: attachment; filename=$this->xls_dosyaxls");
header("Pragma: no-cache");
header("Expires: 0");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
echo $this->xls_data;
}
}
?>



kullanımına örnek;

<?
include( "xlsphp" );
$myxls = new xlsolustur();
$myxls->basla();
$myxls->hucre(0,0,'Bu dosya PHP ile oluşturulmuştur');
$myxls->hucre(1,0,"Hüseyin");
$myxls->hucre(1,1,"YILDIRIM");
$myxls->hucre(1,2,"forumacilcom");
$myxls->gonder();
?>
</SPAN>
 
Geri