PHP Export Code instance of Word format Data _php instance

Source: Internet
Author: User

The content of this section:
A class of PHP export documents

Example:

Copy Code code as follows:

<?php

/**
* Generate classes for 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 '; The class file is placed under the Include folder under the root directory
$word = new Word ();
Query data fill 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. = ' <table width=800 cellpadding= "6" align= "Center" cellspacing= "5" bgcolor= "#000000" >
<tr bgcolor= "White" height= "M" >
&LT;TD width=80 style= "border:1px solid #c8c8c8;" >igo <br/> dan Number </td>
&LT;TD width=300 style= "border:1px solid #c8c8c8;" ><br/> '. $val [' Box_code ']. ' </td>
&LT;TD width=60 style= "border:1px solid #c8c8c8;" > Date </td>
&LT;TD width=100 style= "border:1px solid #c8c8c8;" > '. Date (' y-m-d ', $val [create_date]). ' </td>
&LT;TD width=100 style= "border:1px solid #c8c8c8;" > Logo <br/> name </td>
&LT;TD width=240 style= "border:1px solid #c8c8c8;" > '. $val [code]. ' /'. $val [' OrderID ']. ' <br/> '. $val [' OrderInfo '] [' user_name ']. ' </td>
</tr>
<tr bgcolor= "White" >
&LT;TD width=60 style= "border:1px solid #c8c8c8;" Number of > Pieces </td>
&LT;TD width=40 style= "border:1px solid #c8c8c8;" >3</td>
&LT;TD width=40 style= "border:1px solid #c8c8c8;" > Weight </td>
&LT;TD width=150 style= "border:1px solid #c8c8c8;" >56.5</td>
&LT;TD width=40 style= "border:1px solid #c8c8c8;" > Name </td>
&LT;TD width=390 style= "border:1px solid #c8c8c8;" > Bite, Sucker Bowl, learn to drink cups, dried fish oil </td>
</tr>
<tr bgcolor= "White" >
&LT;TD width=110 style= "border:1px solid #c8c8c8;" > Services <br/> Categories </td>
&LT;TD width=200 style= "border:1px solid #c8c8c8;" > Warehouse Services </td>
&LT;TD width=110 style= "border:1px solid #c8c8c8;" > Services <br/> Requirements </td>
&LT;TD width=280 style= "border:1px solid #c8c8c8;" > Small Box </td>
</tr>
<tr bgcolor= "White" >
&LT;TD width=120 style= "border:1px solid #c8c8c8;" ><br/><br/> Customer <br/> Notes <br/><br/></td>
&LT;TD width=580 style= "border:1px solid #c8c8c8;" > '. $val [' OrderInfo '] [' Beizhu ']. ' </td>
</tr>
<tr bgcolor= "White" >
&LT;TD width=120 style= "border:1px solid #c8c8c8;" ><br/><br/><br/> Arrival <br/> Situation <br/><br/><br/><br/></td>
&LT;TD width=580 style= "border:1px solid #c8c8c8;" > What's the problem? What's the point of <br/>? What's the point of <br/>? The fruit is not up to <br/><br/><br/><br/><br/><br/><br/><br/></td>.
</tr>
</table> <br/><br/><br/><br/>
';
}
$word->start ();
$filename = ' Picking manifest export. doc ';
Echo $html;
$word->save ($filename);

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

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.