/**
* 生成word文档的类
*
*/
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);
}
}//导出的程序文件
//导出 ---start---
require SITE_ROOT.'include/word.class.PHP'; //类文件放在根目录下的include文件夹下
$word = new word();
//查询数据填入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 .='
| 单号 |
'.$val['Box_code'].' | | | 姓名 | '.$val['orderinfo']['user_name'].'
| | | | | |
| 类别 | | 要求 |
|
客户
备注
|
|
到货
情况
| 什么问题?果点不到
什么问题?果点不到
';
}
$word->start();
$filename = '拣货单导出.doc';
echo $html;
$word->save($filename); //文件的类型
header('Content-type: application/word');
header('Content-Disposition: attachment; filename="拣货单导出.doc"');
readfile($filename);
ob_flush();
flush();
exit();
//导出word --end--