Share an example of PHP code to export word format files, a PHP class that exports content into word documents, share it with everyone, and interested friends can learn from it.
Contents of this section:
A PHP class to export word documents
Example:
01
02
/**
03
* Class for generating word documents
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
Arrival Situation
|
77
| What’s the problem? I can’t get any results
What’s the problem? Not enough fruit
78
79
< ;br/>
80
';
81
}
82
$word->start();
83
$filename = 'pick Export manifest.doc';
84
echo $html;
85
$word->save($filename);
86
87
//Type of file
88
header('Content-type: application/word');
89
header('Content-Disposition: attachment; filename="Pick list export.doc "');
90
readfile($filename);
91
ob_flush();
92
flush();
93
exit();
94
//Export word --end--
Articles you may be interested in:
A simple example of php exporting a word file
A simple example of php exporting a word document
Solution to page view and style issues after php exports Word
Example code for php exporting word format documents
The best way to generate excel or word documents using php Simple method
php generates word document (read database)
The simplest example of php generating word
php uses phpword to generate word Document example
Simple example of php generating word file
php generates code to export word (can include pictures)
php generated Word example
Introduction to php code for exporting web pages into Word documents
php uses phpword to generate word documents
Original reference: http://www.jbxue .com/article/13631.html
http://www.bkjia.com/PHPjc/699431.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/699431.htmlTechArticleShare an example of PHP code to export word format files, a PHP class that exports word documents, share it with everyone, Interested friends can refer to it for reference. Contents of this section: A php export w...