PHP Export the Word Format Data code _php Tutorial

Source: Internet
Author: User
Tags php class phpword

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 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 Operations
Number

'. $val [' Box_code ']. '
Date'. Date (' y-m-d ', $val [create_date]). 'Marked
Name
'. $val [code]. ' /'. $val [' OrderID ']. '
'. $val [' OrderInfo '] [' user_name ']. '
Number of pieces3Weight56.5NameBite, suction bowl, learn to drink, dried fish oil
Service
Category
Warehouse ServiceService
Requirements
Fit Small Box


Customer
Note

'. $val [' OrderInfo '] [' Beizhu ']. '



Arrival
Case



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.












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 ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    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.