分享一例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
iGo運
單號 | 51
'.$val['box_code'].' | 52
日期 | 53
'.date('Y-m-d',$val[create_date]).' | 54
標示
姓名 | 55
'.$val[code].'/'.$val['orderid'].'
'.$val['orderinfo']['user_name'].' | 56
57
58
| 件數 | 59
3 | 60
重量 | 61
56.5 | 62
品名 | 63
咬咬了,吸盤碗,學飲杯,魚乾油 | 64
65
66
服務
類別 | 67
庫房服務 | 68
服務
要求 | 69
合小箱 | 70
71
72
客戶
備忘
| 73
'.$val['orderinfo']['beizhu'].' | 74
75
76
到貨
情況
| 77
什麼問題?果點不到
什麼問題?果點不到
什麼問題?果點不到
| 78
79
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...