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