PHP Export code example of Word format Data _php tutorial

Source: Internet
Author: User
The content of this section:
A class for a PHP export document

Example:
Copy the Code code as follows:

/**
* Class for generating Word documents
*
*/
Class Word
{
function Start ()
{
Ob_start ();
Echo 'xmlns:w= "Urn:schemas-microsoft-com:office:word"
xmlns= "HTTP://WWW.W3.ORG/TR/REC-HTML40" > ";
}
function Save ($path)
{
echo "";
$data = Ob_get_contents ();
Ob_end_clean ();

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

function Wirtefile ($FN, $data)
{
$FP =fopen ($FN, "WB");
Fwrite ($fp, $data);
Fclose ($FP);
}
}

Exported Program Files
Export---start---
Require site_root. ' include/word.class.php '; Class files are placed under the Include folder under the root directory
$word = new Word ();
Query data fills in Word
$result = $db->query ("SELECT * from". Db_pre. " box where status= ' 9 ' ORDER by Boxid DESC ");
while ($r = $db->fetch_array ($result))
{
$r [' orderinfo '] = $db->get_one ("SELECT * from". Db_pre. " Order where orderid= ' ". $r [' OrderID ']." ' ";
$r [' wrapinfo '] = $db->get_one ("SELECT * from". Db_pre. " Wrap where orderid= ' ". $r [' OrderID ']." ' ");
$boxlist [] = $r;
}

foreach ($boxlist as $key = = $val) {
$order->upcabarcode ($val [' Box_code ']);

$html. = '
































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 pieces 3 Weight 56.5 Name Bite, suction bowl, learn to drink, dried fish oil
Service
Category
Warehouse Service Service
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.












';
}
$word->start ();
$filename = ' pick order export. doc ';
Echo $html;
$word->save ($filename);

Types of files
Header (' Content-type:application/word ');
Header (' content-disposition:attachment; filename= ' pick order export. doc ');
ReadFile ($filename);
Ob_flush ();
Flush ();
Exit ();
Export Word--end--

http://www.bkjia.com/PHPjc/825204.html www.bkjia.com true http://www.bkjia.com/PHPjc/825204.html techarticle This section: an example of a PHP export document class: Copy the code as follows:? PHP/** * Generates a Word document class * */class Word {function start () {Ob_start (); Echo ' HTML xml NS ...

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