Share a sample of PHP export Word format file code, an export content for Word document PHP class, share to everyone, interested friends reference learning under.
The content of this section:
A PHP class for exporting 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
21st
$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
Exported Program Files
33
Export---start---
34
Require site_root. ' include/word.class.php '; Class files are placed under the Include folder under the root directory
35
$word = new Word ();
36
Query data fills in 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 Operations Number | 51
'. $val [' Box_code ']. ' | 52
Date | 53
'. Date (' y-m-d ', $val [create_date]). ' | 54
Marked Name | 55
'. $val [code]. ' /'. $val [' OrderID ']. ' '. $val [' OrderInfo '] [' user_name ']. ' | 56
57
58
Number of pieces | 59
3 | 60
Weight | 61
56.5 | 62
Name | 63
Bite, suction bowl, learn to drink, dried fish oil | 64
65
66
Service Category | 67
Warehouse Service | 68
Service Requirements | 69
Fit Small Box | 70
71
72
Customer Note
| 73
'. $val [' OrderInfo '] [' Beizhu ']. ' | 74
75
76
Arrival Case
| 77
What's the problem? The fruit is not there. What's the problem? The fruit is not there. What's the problem? The fruit is not there.
| 78
79
80
';
81
}
82
$word->start ();
83
$filename = ' pick order export. doc ';
84
Echo $html;
85
$word->save ($filename);
86
87
Types of files
88
Header (' Content-type:application/word ');
89
Header (' content-disposition:attachment; filename= ' pick order 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 Word files
A simple example of PHP exporting Word documents
Workaround for Page view and style issues after PHP export word
PHP Export Instance code for Word format documents
The easiest way for PHP to generate Excel or Word documents
PHP generates Word document (read database)
The simplest example of PHP generating word
Example of PHP using Phpword to generate Word documents
A simple example of a Word file generated by PHP
PHP generates code that exports word (which can contain pictures)
Example of Word generated by PHP
Introduction to PHP code for exporting Web pages as Word documents
PHP uses Phpword to generate Word documents
Original reference: Http://www.jbxue.com/article/13631.html
http://www.bkjia.com/PHPjc/699431.html www.bkjia.com true http://www.bkjia.com/PHPjc/699431.html techarticle share a sample of PHP export Word format file code, an export content for Word document PHP class, share to everyone, interested friends reference learning under. This section: a PHP export w ...