php匯出word格式資料的代碼_PHP教程

來源:互聯網
上載者:User

分享一例php匯出word格式檔案的代碼,一個匯出內容為word文檔的php類,分享給大家,感興趣的朋友參考學習下。
本節內容:
一個php 匯出word文檔的類

例子:

01
02
/**
03
* 產生word文檔的類
04
* by www.jbxue.com
05
*/
06
class word
07
{
08
function start()
09
{
10
ob_start();
11
echo '
12
xmlns:w="urn:schemas-microsoft-com:office:word"
13
xmlns="http://www.w3.org/TR/REC-html40">';
14
}
15
function save($path)
16
{
17
echo "";
18
$data = ob_get_contents();
19
ob_end_clean();
20

21
$this->wirtefile ($path,$data);
22
}
23

24
function wirtefile ($fn,$data)
25
{
26
$fp=fopen($fn,"wb");
27
fwrite($fp,$data);
28
fclose($fp);
29
}
30
}
31

32
//匯出的程式檔案
33
//匯出 ---start---
34
require SITE_ROOT.'include/word.class.php'; //類檔案放在根目錄下的include檔案夾下
35
$word = new word();
36
//查詢資料填入word 中
37
$result = $db->query("SELECT * FROM ".DB_PRE."box where status='9' order by boxid DESC");
38
while($r = $db->fetch_array($result))
39
{
40
$r['orderinfo'] = $db->get_one("SELECT * FROM ".DB_PRE."order where orderid='".$r['orderid']."'");
41
$r['wrapinfo'] = $db->get_one("SELECT * FROM ".DB_PRE."wrap where orderid='".$r['orderid']."'");
42
$boxlist[] = $r;
43
}
44

45
foreach($boxlist as $key=>$val){
46
$order->UPCAbarcode($val['box_code']);
47

48
$html .='































































49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
iGo運
單號

'.$val['box_code'].'
日期'.date('Y-m-d',$val[create_date]).'標示
姓名
'.$val[code].'/'.$val['orderid'].'
'.$val['orderinfo']['user_name'].'
件數3重量56.5品名咬咬了,吸盤碗,學飲杯,魚乾油
服務
類別
庫房服務服務
要求
合小箱


客戶
備忘

'.$val['orderinfo']['beizhu'].'



到貨
情況



什麼問題?果點不到
什麼問題?果點不到
什麼問題?果點不到












80
';
81
}
82
$word->start();
83
$filename = '揀貨單匯出.doc';
84
echo $html;
85
$word->save($filename);
86

87
//檔案的類型
88
header('Content-type: application/word');
89
header('Content-Disposition: attachment; filename="揀貨單匯出.doc"');
90
readfile($filename);
91
ob_flush();
92
flush();
93
exit();
94
//匯出word --end--

您可能感興趣的文章:
php匯出word檔案的簡單例子
php 匯出word文檔的簡單樣本
php匯出Word後整頁模式和樣式問題的解決方案
php匯出word格式文檔的執行個體代碼
php產生excel或word文檔的最簡單方法
php產生word文檔(讀取資料庫)
php產生word最簡單的例子
php使用phpword產生word文檔的例子
php產生word檔案的簡單範例
php 產生 匯出word(可包含圖片)的代碼
php產生word的例子
將網頁匯出為Word文檔的php代碼介紹
php使用phpword產生word文檔
原文參考:http://www.jbxue.com/article/13631.html

http://www.bkjia.com/PHPjc/699431.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/699431.htmlTechArticle分享一例php匯出word格式檔案的代碼,一個匯出內容為word文檔的php類,分享給大家,感興趣的朋友參考學習下。 本節內容: 一個php 匯出w...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.