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 .='
iGo運 單号 | | 日期 | '.date('Y-m-d',$val[create_date]).' | 标示 姓名 | '.$val[code].'/'.$val['orderid'].' '.$val['orderinfo']['user_name'].' |
件數 | 3 | 重量 | 56.5 | 品名 | 咬咬了,吸盤碗,學飲杯,魚幹油 |
服務 類别 | 庫房服務 | 服務 要求 | 合小箱 | ||
客戶 備注 | '.$val['orderinfo']['beizhu'].' | ||||
到貨 情況 | 什麼問題?果點不到 什麼問題?果點不到 什麼問題?果點不到 |
';
}
$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--