欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

php,不用COM,生成excel文件

 更新時(shí)間:2006年10月09日 00:00:00   作者:  
用php生成excel文件  

<?
header("Content-type:application/vnd.ms-excel");
header("Content-Disposition:filename=test.xls");
echo "test1\t";
echo "test2\t\n";
echo "test1\t";
echo "test2\t\n";
echo "test1\t";
echo "test2\t\n";
echo "test1\t";
echo "test2\t\n";
echo "test1\t";
echo "test2\t\n";
echo "test1\t";
echo "test2\t\n";
?>
  在php環(huán)境運(yùn)行上面的代碼,大家就可以看到瀏覽器詢問用戶是否下載excel文檔,點(diǎn)擊保存,硬盤上就多了一個(gè)excel的文件,使用excel打開就會(huì)看到最終的結(jié)果,怎么樣不錯(cuò)吧。
  其實(shí)在做真正的應(yīng)用的時(shí)候,大家可以將數(shù)據(jù)從數(shù)據(jù)庫中取出,然后按照每一列數(shù)據(jù)結(jié)束后加\t,每一行數(shù)據(jù)結(jié)束后加\n的方法echo出來,在php的開頭用header("Content-type:application/vnd.ms-excel");表示輸出的是excel文件,用header("Content-Disposition:filename=test.xls");表示輸出的文件名為text.xls。這樣就ok了。



  我們更可以修改header讓他輸出更多格式的文件,這樣php在處理各種類型文件方面就更加方便了.

相關(guān)文章

最新評(píng)論