Content of this section:
A php document export class
Example:
Copy codeThe Code is as follows:
<? Php
/**
* Word document generation class
*
*/
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 );
}
}
// Export the program file
// Export --- start ---
Require SITE_ROOT. 'include/word. class. php'; // put the class file in the include folder under the root directory
$ Word = new word ();
// Enter the query data 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 ['rapinfo'] = $ 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 = "50">
<Td width = 80 style = "border: 1px solid # c8c8c8;"> iGo <br/> Ticket No. </td>
<Td width = 300 style = "border: 1px solid # c8c8c8;"> <br/> '. $ val ['box _ Code']. '</td>
<Td width = 60 style = "border: 1px solid # c8c8c8;"> date </td>
<Td width = 100 style = "border: 1px solid # c8c8c8;"> '. date ('Y-m-d', $ val [create_date]). '</td>
<Td width = 100 style = "border: 1px solid # c8c8c8;"> name <br/> </td>
<Td width = 240 style = "border: 1px solid # c8c8c8;"> '. $ val [code]. '/'. $ val ['orderid']. '<br/> '. $ val ['orderinfo'] ['user _ name']. '</td>
</Tr>
<Tr bgcolor = "White">
<Td width = 60 style = "border: 1px solid # c8c8c8;"> Number of parts </td>
<Td width = 40 style = "border: 1px solid # c8c8c8;"> 3 </td>
<Td width = 40 style = "border: 1px solid # c8c8c8;"> weight </td>
<Td width = 150 style = "border: 1px solid # c8c8c8;"> 56.5 </td>
<Td width = 40 style = "border: 1px solid # c8c8c8;"> product name </td>
<Td width = 390 style = "border: 1px solid # c8c8c8;"> bit, suction bowl, xueyin cup, dried fish oil </td>
</Tr>
<Tr bgcolor = "White">
<Td width = 110 style = "border: 1px solid # c8c8c8;"> service <br/> Category </td>
<Td width = 200 style = "border: 1px solid # c8c8c8;"> warehouse service </td>
<Td width = 110 style = "border: 1px solid # c8c8c8;"> service <br/> requirements </td>
<Td width = 280 style = "border: 1px solid # c8c8c8;"> small box </td>
</Tr>
<Tr bgcolor = "White">
<Td width = 120 style = "border: 1px solid # c8c8c8; "> <br/> customer <br/> remarks <br/> </td>
<Td width = 580 style = "border: 1px solid # c8c8c8;"> '. $ val ['orderinfo'] ['beizhu'].' </td>
</Tr>
<Tr bgcolor = "White">
<Td width = 120 style = "border: 1px solid # c8c8c8; "> <br/> arrival status <br/> </td>
<Td width = 580 style = "border: 1px solid # c8c8c8;"> what is the problem? If not, <br/> what is the problem? If not, <br/> what is the problem? If not, <br/> </td>
</Tr>
</Table> <br/>
';
}
$ Word-> start ();
$ Filename = 'picking ticket export .doc ';
Echo $ html;
$ Word-> save ($ filename );
// File type
Header ('content-type: application/word ');
Header ('content-Disposition: attachment; filename = "Picking ticket export .doc "');
Readfile ($ filename );
Ob_flush ();
Flush ();
Exit ();
// Export word -- end --