php导出word格式数据的代码实例_php实例
本节内容:
一个php导出文档的类
例子:
/**
* 生成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 .='
iGo运 单号 |
'.$val['box_code'].' | 日期 | '.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--

핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

AI Hentai Generator
AI Hentai를 무료로 생성하십시오.

인기 기사

뜨거운 도구

메모장++7.3.1
사용하기 쉬운 무료 코드 편집기

SublimeText3 중국어 버전
중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기
강력한 PHP 통합 개발 환경

드림위버 CS6
시각적 웹 개발 도구

SublimeText3 Mac 버전
신 수준의 코드 편집 소프트웨어(SublimeText3)

뜨거운 주제











Ubuntu 및 Debian용 PHP 8.4 설치 및 업그레이드 가이드

PHP 개발을 위해 Visual Studio Code(VS Code)를 설정하는 방법
