php生成excel文件的簡單方法
更新時間:2014年02月08日 15:57:38 作者:
生成excel文件,最簡單的莫過于把數(shù)據(jù)庫的數(shù)據(jù)導入到excel就行了,下面有個不錯的示例,大家可以參考下
生成excel 當然使用的是 phpExcel這個類庫了,可是它太麻煩了,對于只要簡單生成來說有點不值得
什么叫簡單,把數(shù)據(jù)庫的數(shù)據(jù)導入到excel就行了, 這個就是簡單了
下面看一段代碼(代碼來自網(wǎng)絡)
注意要雙引號的字符串
<?php
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";
?>
運行就會下載test.xls這個文件,打開以后他是這樣的
什么叫簡單,把數(shù)據(jù)庫的數(shù)據(jù)導入到excel就行了, 這個就是簡單了
下面看一段代碼(代碼來自網(wǎng)絡)
注意要雙引號的字符串
復制代碼 代碼如下:
<?php
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";
?>
運行就會下載test.xls這個文件,打開以后他是這樣的
您可能感興趣的文章:
- PHP讀取Excel內(nèi)的圖片(phpspreadsheet和PHPExcel擴展庫)
- 利用phpExcel實現(xiàn)Excel數(shù)據(jù)的導入導出(全步驟詳細解析)
- PHPExcel讀取Excel文件的實現(xiàn)代碼
- PHP導入Excel到MySQL的方法
- php讀取EXCEL文件 php excelreader讀取excel文件
- php導入導出excel實例
- ThinkPHP使用PHPExcel實現(xiàn)Excel數(shù)據(jù)導入導出完整實例
- php中使用PHPExcel讀寫excel(xls)文件的方法
- phpExcel導出大量數(shù)據(jù)出現(xiàn)內(nèi)存溢出錯誤的解決方法
- php中導出數(shù)據(jù)到excel時數(shù)字變?yōu)榭茖W計數(shù)的解決方法
- PHP上傳Excel文件導入數(shù)據(jù)到MySQL數(shù)據(jù)庫示例
- 基于PHPExcel的常用方法總結(jié)
- PHP使用PhpSpreadsheet操作Excel實例詳解
相關文章
在MongoDB中模擬Auto Increment的php代碼
MySQL用戶多半都有Auto Increment情結(jié),不過MongoDB缺省并沒有實現(xiàn),所以需要模擬一下,編程語言以PHP為例2011-03-03
php中json_encode不兼容JSON_UNESCAPED_UNICODE的解決方案
本文主要介紹針對PHP5.4以下版本的json_encode不兼容JSON_UNESCAPED_UNICODE的處理,需要的朋友可以參考下。2016-05-05

